linux - How to write a path that include environment variables? -
i'm writing qt app runs in linux. need write file to:
"$xdg_config_dirs/whatever"/ "$home/whatever"
how resolve environment variables ## heading ##in code?
using nothing plain library functions, use getenv()
value of environment variables:
const char *dirs = getenv("xdk_config_dirs");
this return null
if variable not set in environment, make sure code handles case.
you'll have "interpolation" of variable values rest of text yourself, in case.
not sure if qt provides wrapper or more high-level can interpolation you, haven't worked qt.
Comments
Post a Comment