Doubt in command of entry in program in C ++

1

I'm learning functions now in C ++ and behold, I've been trying to run this program. It turns out that when I run it it just will not let me type the value of cin>>p; it just ignores the command and moves on to the next one. I do not know what is happening. The program is this:

#include <iostream>
#include <conio.h>
using namespace std;

float p,mai=0;
int i;
char nome,pesado;

void topo(){
    system("cls");
    cout<<"------------------------------------"<<endl;
    cout<<" D E T E C T O R  DE  P E S A D O"<<endl;
    cout<<" Maior peso ate agora: "<<mai<<" kg"<<endl;
    cout<<"------------------------------------"<<endl;
}

int main (void) {
    topo ();
    do{
        i+=1;
        cout<<"Digite o nome e depois o peso: "<<endl;
        cin>>nome;
        cout<<"\n";
        cin>>p; 
        if (p>mai){
            mai =p;
            pesado =nome;
        }
    topo();
    }while(i<=5);
    topo();
    cout<<"A pessoa mais pesada foi "<<pesado<<"com "<<mai<<" kg"<<endl;


}
    
asked by anonymous 08.09.2017 / 05:43

1 answer

0

You have to pass a character pointer, not just a character, so it looks like this:

char *nome;
    
19.09.2017 / 19:23