I don't feel like taking out a book, and I'm too lazy to search on google.
How do you make a string accept a space as part of it?
Like, for example:
If the user entered:Code:#include <io.h> #include <sys/types.h> #include <sys/stat.h> #include <iostream> #include <string> using namespace std; int main( void ) { string strPath; cout << "Enter directory to check: "; cin >> strPath; if ( access( strPath.c_str(), 0 ) == 0 ) { struct stat status; stat( strPath.c_str(), &status ); if ( status.st_mode & S_IFDIR ) { cout << "The directory exists." << endl; } else { cout << "The path you entered is a file." << endl; } } else { cout << "Path doesn't exist." << endl; } return 0; }
C:\Program Files\
How would you make it accept the space in "Program Files"? When a normal string sees a space it just cuts off accepting input, seeing the space as the end of the input.
Help, anyone?
Results 1 to 5 of 5
Thread: 'Tarded programming question
Threaded View
- 03 Jul. 2012 02:55am #1
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 15.00
'Tarded programming question