-2
I started studying C++ in college and the teacher asked to make a small script to register 3 people and at the end print the chosen person. I made the script with simple inputs and when I run it just starts the first one and skips all the others and even at the end the result of the variable Name only takes the first letter typed.
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
char nome1,nome2,nome3;
char sexo1,sexo2,sexo3;
int altura1,altura2,altura3;
int cpf1,cpf2,cpf3;
int peso1,peso2,peso3;
cout<<"DIGITE O PRIMEIRO NOME: "<<endl;
cin>>nome1;
cout<<"DIGITE O CPF : "<<endl;
cin>>cpf1;
cout<<"DIGITE O SEXO [M/F] : "<<endl;
cin>>sexo1;
cout<<"DIGITE O PESO: "<<endl;
cin>>peso1;
cout<<"DIGITE A ALTURA EM CENTIMETROS : "<<endl;
cin>>altura1;
cout<<"QUAL PESSOA DESEJA MEDIR O IMC: "<<endl;
cout<<"1 - "<<nome1<<" CPF - "<<cpf1<<endl;
return 0;
}
Utilize
string
in place ofchar
in the declaration of name variables.– Daniel Mendes
Note also that you only treat name1, cpf1, sex1, weight1 and height1. Other variables, with suffix 2 and 3, are declared but ignored.
– anonimo