#include
std::string input;
std::cin >> input;
The user wants to enter \"Hello World\". But cin
fails at the spa
THE C WAY
You can use gets
function found in cstdio(stdio.h in c):
#include
int main(){
char name[256];
gets(name); // for input
puts(name);// for printing
}
THE C++ WAY
gets
is removed in c++11.
[Recommended]:You can use getline(cin,name) which is in string.h
or cin.getline(name,256) which is in iostream
itself.
#include
#include
using namespace std;
int main(){
char name1[256];
string name2;
cin.getline(name1,256); // for input
getline(cin,name2); // for input
cout<