mnichols
asked on
Parsing and separating the command line
Yeah, this is supposed to be an easy task, but I'm having difficulties. This is a Windows program, so the command line doesn't get automatically parsed like it does in DOS programs. here's the code I have so far:
char *pdest;
int result;
int Spc = ' ';
char *Find;
pdest = strchr(szCmdLine, Spc);
result = pdest - szCmdLine + 1;
szCmdLine is a char * that contains the command line. so far I have result storing the position of a space, but what I need now is to store the characters up to the space into a char * and the characters after the space into another char *. I haven't found the substring functions that would be equivalent to Visual Basic's Left(string, length), Right(string, length), and Mid(string, start, length). I'm looking for a code snippet that would accomplish this stuff in C++
char *pdest;
int result;
int Spc = ' ';
char *Find;
pdest = strchr(szCmdLine, Spc);
result = pdest - szCmdLine + 1;
szCmdLine is a char * that contains the command line. so far I have result storing the position of a space, but what I need now is to store the characters up to the space into a char * and the characters after the space into another char *. I haven't found the substring functions that would be equivalent to Visual Basic's Left(string, length), Right(string, length), and Mid(string, start, length). I'm looking for a code snippet that would accomplish this stuff in C++
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually, this comment is for nigel5...
I thought that argv and argc were only applicable to Win32 console programs. I'm making a Win32 application, with a WinMain function instead of a Main function...
-- Matt
I thought that argv and argc were only applicable to Win32 console programs. I'm making a Win32 application, with a WinMain function instead of a Main function...
-- Matt
You can use GetCommandLine, as well as argv in Win32.
(double underscore)