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,356 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 );
![](../../users/profiles/262296.webp)
TiansHUo
- 8,049
- 6
- 42
- 57
2
Use cin.getline()
to read a line? (Or, probably better, as Martin notes in a comment, use std::getline
.)
![](../../users/profiles/15168.webp)
Jonathan Leffler
- 666,971
- 126
- 813
- 1,185
-
prefer std::getline() as you are not dealing with fixed size buffers. – Martin York Apr 05 '11 at 04:27