Below is a code fragment, that I am using to try and check that a drive string entered points to a valid drive.
Watching via the debugger, nDrv is only ever set to 0, which implies that atoi() cannot convert the current value into an integer.
ptrTarget is defined elsewhere in the same function as being a char*, and contains the string "Q:\\test", which is not a valid path on my PC.
So my starter for 10 is, whats happening here that I don't understand ?
And as a bonus question, is _chdrive() the easiest way to check if a drive is valid (I know I still need to handle the fact that the string might be upper or lower case)
K
Code:
//Check to see if the drive is a valid drive
char* s = new char;
*s = ptrTarget[0];
int nDrv = atoi(s);
if (!_chdrive(nDrv))
{
AfxMessageBox("The Target Drive does not exist !",MB_OK);
return;
}
ptrTarget is defined elsewhere in the same function as being a char*, and contains the string "Q:\\test", which is not a valid path on my PC.
So my starter for 10 is, whats happening here that I don't understand ?
And as a bonus question, is _chdrive() the easiest way to check if a drive is valid (I know I still need to handle the fact that the string might be upper or lower case)
K