Hey guys, I just signed up, and I have a question. I am trying to develop a text-based game using Dev C++, and I am trying to get out of the "enter 1 to go east, enter 2 to go north, etc." approach, and am trying to move onto a system in which the user types in what they cant to do. But I need to develop a snippet of code that capitalizes the first letter in a string and lowercases all the others. This is what I have:
// Capitalize the first letter in the string...
szword[0] = toupper( szword[0] );
// ...and lowercase all the others
while (nCaps < 1000)
{
szword[nCaps] = tolower( szword[nCaps] );
nCaps = nCaps + 1;
}
Unfortunately, this system ignores spaces, rendering it useless if a user were to type something like "go east". However, typing "go_east" works. So, I see three solutions (in order of which would be best for me):
One, a version of the above code that ignores the spaces
Two, a snippet of code that turns all spaces into underscores
Three, a section of code that removes all spaces completely
Sorry if there's already been a topic like this, but I've searched to no avail. Thanks in advance!