I am trying something like this,
PROCESS_INFORMATION processInfo = .....
strcat( args, processInfo.dwProcessId);
where args
is a char *
which I need to pass as an argument to another executable.
You can use sprintf
char procID[10];
sprintf(procID, "%d", processInfo.dwProcessId);
This will convert the processInfo.dwProcessId into a character which can then be used by you.
MSDN has pretty good documentation, check out the Data Conversion page.
There's sprintf() too.
To convert DWORD to char * you can use _ultoa / _ultoa_s
see here might help you.link1
While not directly "converting to a char*
", the following should do the trick:
std::ostringstream stream;
stream << processInfo.dwProcessId;
std::string args = stream.str();
// Then, if you need a 'const char*' to pass to another Win32
// API call, you can access the data using:
const char * foo = args.c_str();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With