Cin with space in character string c++. Now you can understand with basic program.
In case of character string :
In case of character string :
#include "stdafx.h" #include <conio.h> #include <iostream> #include <string> using namespace std; int main() { char name[20]; cout << "Enter Your Name:"; cin.getline(name, 20); cout << "My Name is :" << name<<endl; _getch(); return 0; }
Output
Cin with space a string type values like string name.
In case of Simple string :
#include "stdafx.h" #include <conio.h> #include <iostream> #include <string> using namespace std; int main() { string name; cout << "Enter Your Name:"; getline(cin, name); cout << "My Name is :" << name<<endl; _getch(); return 0; }
Output
Post a Comment