+ 1
User Input Help (Solved)
anytime I put user input coding, it only prints numbers and not statements. example: #include <iostream> using namespace std; int main() { int firstName; cin >> firstName; cout << " Enter Your First Name:" << endl; cout << firstName << " " << endl; return 0; } Any help ? thank you in advance.
3 ответов
+ 4
replace int firstName; by string firstName; and add the header #include <string> after iostream
int is the data type for integers = natural numbers.
0
Thank You !
0
using string
#include<iostream.h>
#include<string.h>
int main(){
string s;
cour<<"Enter Firstname";
cin>>f_name;
cout<<"Your Firstname is "<<f_name;
return 0;
}
using character array
#include <iostream.h>
int main(){
char f_name[20];
cout<<"Enter Firstname:";
cin>>f_name;
cout<<"Your Firstname is "<<f_name;
return 0;
}