How to capture a full sentence?

Pages: 12
#include <string>

string sent;

cout << "Enter sentence ";
getline(cin, sent);
if you are using system("something"); getline()won't work. donno why, but it's not working, and it's not the only problem system("something") is causing. try it after you remove system("something")

try using _getch(); from conio.h instead of system("pause");
Last edited on

Don't use getch.

Use one of many solutions that are any good, e.g. cin.get(), cin.ignore(), getchar(), etc.

And why not read Helios' post? One which actually will solve the problem? Its not like he has a bad reputation. He knows what he's talking about.

Helios,
Damn! I should have thought of that!
erm, i dont mean to hijack the thread but i tried to use getline with the exact formatting you guys gave in a program, it DOESN'T use system, but it still didn't work, it didn't ask for the input at all, it just skipped over it and said Query is empty (its an sql program)
Topic archived. No new replies allowed.
Pages: 12