-
How do I read an entire string when i use cin. The problem is that cin stops reading at the first white space. One other thing. How come when I go to open a file using fopen I have to type the path in with the '/' instead of say C:\ i use C:/. Thanks
-
You should write cin in this syntax:
cin.getline(str1, 30, '\n');
Where str1 is the string name, 30 is the length of characters u wish to read, and the last parameter, will stop reading after reading in a Nextline (you can set any characters to be the terminator here).
Hope this helps :)
-
would you happen to know the header needer for that? Thanks
-
It's in <iostream>:
Code:
#include <iostream>
#include <string>
using namespace std;
void main() {
string sInput;
cin.getline(sInput, 30, '\n');
}
-