PDA

Click to See Complete Forum and Search --> : Why is it ignoring part of my code?


SteveCRM
Jan 6th, 2001, 07:32 PM
char Name[101];
int Phone;
char Address[101];
cout<<"Enter the name of a person: "<<endl<<">";
cin.getline(Name,101,'\n');
cout<<"Enter "<<Name<<"'s phone number: "<<endl<<">";
cin>>Phone;
cout<<"Enter "<<Name<<"'s address: "<<endl<<">";
cin.getline(Address,101,'\n');

cout<<"========================================"<<endl;
cout<<"Name: "<<Name<<endl<<"Phone: "<<Phone<<endl<<"Address: "<<Address<<endl;

This is my code, but when it runs, it doesn't execute the bold part. Why is this? Is it just my computer?

SteveCRM
Jan 6th, 2001, 08:05 PM
It works now but only because I changed the Phone number to a string. Can you only call these once? Do I have to call something to end a getline?

BoB
Jan 7th, 2001, 08:00 AM
does the address have a space in it sometime a compiler mite think the space is the send of it . but i dont know

Jop
Jan 7th, 2001, 09:27 AM
I tend to use stdio.h's Gets to get a whole line.


void Main()
{
char sIn[120];
gets(sIn); //get the whole line
return;
}

SteveCRM
Jan 7th, 2001, 10:05 AM
Its not because of a space (I've tried it with my name) and the ending character is '\n'