Click to See Complete Forum and Search --> : i/o
MPrestonf12
Feb 27th, 2001, 06:10 PM
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
Blitz
Feb 27th, 2001, 09:32 PM
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 :)
MPrestonf12
Mar 3rd, 2001, 10:59 AM
would you happen to know the header needer for that? Thanks
parksie
Mar 3rd, 2001, 11:01 AM
It's in <iostream>:
#include <iostream>
#include <string>
using namespace std;
void main() {
string sInput;
cin.getline(sInput, 30, '\n');
}
MPrestonf12
Mar 3rd, 2001, 11:11 AM
great, thanks!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.