Attia Noor
0
Q:

how to declare string in c++ and taking the input

string fullName;
cout << "Type your full name: ";
getline (cin, fullName);
cout << "Your name is: " << fullName;
10

  string firstName; //unlike array, no need to mention the size of the sting
cout << "Type your first name: "; 
cin >> 
  firstName; //this is important
  // get user input from the keyboard
cout << "Your name is: " << 
  firstName;

// Type your first name: John
// Your name is: John 
0

New to Communities?

Join the community