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 i开发者_JAVA技巧t ends the input after one word...(using cin)...how would I get cin to not stop taking input until I hit return?
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 );
You want to use getline to read a full line.
Use cin.getline()
to read a line? (Or, probably better, as Martin notes in a comment, use std::getline
.)
精彩评论