#include <iostream>
#include <string>
using namespace std;
void main()
{
string s1;
cout << "Enter string"<<endl;
getline(cin,s1);
cout << "You entered: " << s1;
}
It takes what the user enters but then you have to hit enter again. Is there anyway to fix this? I tried getline(cin,s1, '\n')
but the same thing still happens. And does anyone know of any good tutorials on the net about c++ strings?
Edited by - dj9781 on 7/1/00 4:30:08 PM
c++ strings
Im having trouble with c++ strings. I want to have the user enter a string with spaces in it but I cant seem to get it to work right. Heres my code:
wow, a console app.
I havt done anything with it in a while but i think you use
getch()... Ill just say its an excercise to figure out how
exactly
I havt done anything with it in a while but i think you use
getch()... Ill just say its an excercise to figure out how
exactly
July 02, 2000 03:25 AM
Theres a bug in the getline function with some visual c++ compiler versions. There is a fix on the microsoft devnet website you may want to look at.....
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement