I'm just learning some stuff about cryptography and I made a cool program to encrypt any message by rotating the letters through the alphabet a given number of letters...anyway...I have it all set up but I can't give it multiple words to encrypt because it ends the input after one word...(using cin)...how would I get cin to not stop taking input until I hit return?
Asked
Active
Viewed 1,554 times
3 Answers
3
How about std::getline()
?
http://www.cplusplus.com/reference/iostream/istream/getline.html
Example:
#include <iostream>
#include <string>
using namespace std;
string line;
getline( std::cin, line );

TiansHUo
- 8,509
- 7
- 45
- 57
2
Use cin.getline()
to read a line? (Or, probably better, as Martin notes in a comment, use std::getline
.)

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278
-
prefer std::getline() as you are not dealing with fixed size buffers. – Martin York Apr 05 '11 at 04:27