Sentencia getline
Categorías: Lenguaje C++ |
1 // cin con cadenas de caracteres
2 #include <iostream>
3 #include <string>
4 using namespace std;
5
6 int main ()
7 {
8 string nombre, color;
9 cout << "Cual es tu nombre? ";
10 getline (cin, nombre);
11 cout << "Hola " << nombre << ".\n";
12 cout << "Cual es tu color favorito\? ";
13 getline (cin, color);
14 cout << nombre ", a mi me gusta el " << color << " tambien!\n";
15 return 0;
16 }
