Store space with cin.getline

0

Do I need support to be able to store several data in cin , separated by a blank space?

CODE:

cout << "\n\tEscriba Curp de cada integrante de la familia separado por un espacio " << i + 1 << ":";
cin.getline(*curp,18); >> usuario[i].curp;

ERROR:

  

curp was not declared in this shot error
     expected primary-expression before '> > token

If I do not use .getline(*curp,18); everything works fine.

    
asked by Acidous 01.09.2018 в 06:07
source

1 answer

0

The error you have is clear and concise. Maybe you do not understand it because it's in English, let me translate it:

  

curp was not declared in this shot error
     expected primary-expression before '> > token

It would be

  

curp has not been declared in this context error
     a primary expression was expected before the '> >' symbol

The error clearly states that you are using the variable curp but the variable does not exist where you use that variable.

cin.getline(*curp,18); >> usuario[i].curp;
//           ~~~~ <--- 'curp' no existe en este contexto
//                   (curp was not declared in this escope)

The second part of the error refers to the use of the data extraction operator ( >> ) indicating that it expected an expression before it; he complains because in your code there is no expression on his left:

cin.getline(*curp,18); >> usuario[i].curp;
//                   ~^~ <--- nada a la izquierda de '>>'
//          (error expected primary-expression before '>>' token)

As your code is structured, I get the feeling that you wanted to do the following:

std::cin >> usuario[i].curp;
    
answered by 03.09.2018 в 07:43