I'm using Dev-C++ on XP. The last three programs went fine, but now the cmd prompt disappears before I can read the output. I'm using system("PAUSE"); but it no longer pauses after I input the ISBN number.
Actually, if I input a ridiculously long ISBN number it will pause.
That's because your program crashes. You're using string::erase the wrong way. see http://www.cplusplus.com/reference/string/string/erase/
The one you need is string& erase ( size_t pos = 0, size_t n = npos );
turn isbnStr.erase(isbnStr[i]); to isbnStr.erase(i, 1);
By the way, note that operator[] returns a char and not he integer value . That is, '0' == 48. Are you sure you want to do maths with them?
You never initialize your sum variable. It will most likely be a lot of garbage.
One problem I see is when you call erase on a string. The version your calling (1 parameter) is the pos to start deleting. I think you want to pass in i. Could be corrupting the stack, that's why it's not pausing.
1 2 3 4 5 6 7 8
for( int i = 0; i < isbnStr.length(); i++ )
{
if( !isdigit(isbnStr[i]) )
{
//isbnStr.erase(isbnStr[isbnStr.length() - 1]);
isbnStr.erase( i );
}
}