Skip to main content
gamedev.net
🔒 Locked

string manipulation..

Started by anekin Apr 13, 2002 at 1:52 AM 2 replies 700+ views
Original Post
anekin
anekin
Hi..I''m writing a console program for renaming some files and one of the inputs is a path to the directory where the files are located. The problem is that some of the directory names include blank spaces and when I read the variable is cut. This is a part of my code... char DirectoryName[MAX_PATH]; cin>>DirectoryName; If I write for example "My Files" I only get "My". There is a way to fix this problem. There must be an easy to work with blank spaces in a string, right? Thanks.
------------------------------I prefer to be the worst of the best than the best of the worst------------------------------
barazor
barazor
for your type of string(c style char array), use cin.getline(string,size), e.g.:

cin.getline(DirectoryName,sizeof(DirectoryName));

or even better, use std::string and std::getline():

std::string somestring;
std::getline(cin,somestring);
anekin
anekin
Thank. I had forgotten to use the cin.getline function.

Thank U for reminding me...hahahaha
------------------------------I prefer to be the worst of the best than the best of the worst------------------------------

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.