I am extracting environment variables in win32 using GetEnvironmentStrings() . It returns char* .
I want to find this line (char pointer) for a specific environment variable (yes, I know I can use GetEnvironmentVariable() , but I do it this way because I also want to print all the environment variables in the console as well - I just messed around) .
So, I thought that I would convert char* to std :: string and use find on it (I know that I can also use the c_string search function, but I'm more concerned about trying to copy char* to std::string ). But the following code does not seem to copy all char* to std::string (this makes me think that char* has the \0 character, but this is actually not the end).
char* a = GetEnvironmentStrings(); string b = string(a, sizeof(a)); printf( "%s", b.c_str() );
Is there a way to copy char* to std::string (I know that I can use strcpy() to copy const char* to a string, but not char* ).
source share