I was just wondering how I should go about storing the content of a pointer into a variable, particularly something along the lines of:
somethingpoint = getenv(somethingsomething);
This pointer would refer to a string .
You need to declare a pointer variable, and then assign to it. You can do this all in one line of code, like this:
const char *value = getenv(name);
I'm using const
here because getenv
returns a pointer to a string whose contents must not be modified by the program. Using const
lets the compiler help us honour that contract.
const char* test = getenv(pointerName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.