I've spent many hours on here looking for help on what is apparently a common error but none that I've seen seems to fit my case.
I am migrating a old out sourced program that was written in Visual Studio 6 C++ to Visual Studio 2012 and fortunately for me as I'm not a C++ programmer (just a lowly VB and C# developer). The migration wizard and the internet have been a great help in helping me find and correct code that the wizard can't handle.
In this code block which I believe is doing nothing more than creating a directory
int CreateAllDirectories(const char* pszDir)
{
char* pszLastSlash;
char cTmp;
if( _access( pszDir, 0 ) != -1 ) {
// it already exists
return 0;
}
pszLastSlash = strrchr( pszDir, '\\' );
if ( pszLastSlash ) {
cTmp = *pszLastSlash;
*pszLastSlash = '\0';
// try again with one less dir
CreateAllDirectories( pszDir );
*pszLastSlash = cTmp;
}
if ( _mkdir( pszDir ) == -1 ) {
return -1;
}
return 0;
}
an error generates when the results of strrchr( pszDir, '\' ) are assigned to the variable pszLastSlash. From the rest of this code it looks like pszLastSlash = strrchr( pszDir, '\' ); is a valid expression.
Is the issue with the double backslash which to me looks like and escape sequence.