|
Thread: i/o
-
Feb 27th, 2001, 07:10 PM
#1
Thread Starter
Hyperactive Member
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
Last edited by MPrestonf12; Feb 27th, 2001 at 07:38 PM.
Matt 
-
Feb 27th, 2001, 10:32 PM
#2
Lively Member
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
-
Mar 3rd, 2001, 11:59 AM
#3
Thread Starter
Hyperactive Member
would you happen to know the header needer for that? Thanks
Matt 
-
Mar 3rd, 2001, 12:01 PM
#4
Monday Morning Lunatic
It's in <iostream>:
Code:
#include <iostream>
#include <string>
using namespace std;
void main() {
string sInput;
cin.getline(sInput, 30, '\n');
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 3rd, 2001, 12:11 PM
#5
Thread Starter
Hyperactive Member
Matt 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|