-
Code:
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?
-
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?
-
does the address have a space in it sometime a compiler mite think the space is the send of it . but i dont know
-
I tend to use stdio.h's Gets to get a whole line.
Code:
void Main()
{
char sIn[120];
gets(sIn); //get the whole line
return;
}
-
Its not because of a space (I've tried it with my name) and the ending character is '\n'