-
substring error
I get this error when I compile my code and all I am trying to do is get a substring. Any suggestions.
char szDrive[MAX_PATH]="c:\\";
char dir[MAX_PATH]; BOOL bRet;
bRet=GetCurrentDirectory(MAX_PATH,dir);
printf("Current Working Directory is %s\n",dir);
error C2228: left of '.substr' must have class/struct/union type
The printf statement works just fine.
-
well you could start by posting the relevant code
-
It's because you are trying to use the .substr string memeber function on something other than a string.
Perhaps you are trying to something like
szDrive.substr(1,5) or something, but szDrive is a char*, not a std::string. I'd recommend just using the std::string class rather than char*, so you don't have to worry about overflowing your allocated memory, and all that other painful stuff associated with null terminated strings.
-
PROBLEMS ALL RESOLVED...THANKS FOR SUGGESTIONS!