Hey Guys! I was just practicing structure in C++ but I got stuck. When I run the following code, Program skips input of Name. Have a look to it and run it. You will get to know the problem.
#include<iostream>#include<stdio.h>using namespace std;struct student{int SrNo;string Name;string FName;int Class;void input(){cout << "Enter SrNo. :";cin >> SrNo;cout << "Enter Name :";gets(Name);cout << "Enter Father's Name :";gets(FName);cout << "Enter Class :";cin >> Class;}void output(){cout << "SrNo. :";cout << SrNo << endl;cout << "Enter Name :";cout << Name << endl;cout << "Enter Father's Name :";cout << FName << endl;cout << "Enter Class :";cout << Class << endl;}};int main(){student s;cout << "Enter details of Student 1 :" << endl;s.input();cout << "Details of Student 1 :" << endl;s.output();return 0;}
Help me ASAP!