0

Problem with my code

The first loop works, and I want to make my program ask if the user wants to enter another entry . It loops back when I input the entry to be 'Y' ,but it skips the name input going to the address input instead not sure why #include <iostream> #include <string> using namespace std; void displayall(); void displayentry(); struct Info { string name; string Address; string PhoneNum; }; int main() { Info person[5]; char op; char op2; char entry; cout<<"Information entry"<<endl; cout<<"_____________________"<<endl; for(int i=0; i<4; i++) { cout<<"\nPlease enter your name: "; getline(cin,person[i].name); ///call to cin to allow spacing in between words cout<<"Please enter your address: "; getline(cin,person[i].Address); cout<<"Please enter your Phone Number: "; getline(cin,person[i].PhoneNum); cout<<"Information saved"<<endl; cout<<"Another entry?(Y/N): "; cin>>entry; if(entry=='Y') { continue; } else { break; }

20th Jul 2017, 10:58 PM
Chris
Chris - avatar
1 Answer
0
you didn't close main function and for loop. you forgot return 0;
21st Jul 2017, 4:37 AM
‎ ‏‏‎Anonymous Guy