'Tarded programming question
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:
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;
}
If the user entered:
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?