i want to write a program that can let user input the data in the function call "reg" as show at below:
Code:
 void reg()
  {
   i=1;
   std[i].dob=std[i].mob=std[i].yob=0;
   cout<<"Enter Student Name   : ";
   cin.ignore();
   cin.getline(std[i].name,100);
   cout<<"Enter Student IC     : ";
   cin.ignore();
   cin>>std[i].ic;
   cout<<"Enter Student Gender : ";
   cin.ignore();
   cin>>std[i].gender;
   cout<<"Enter Student Course : ";
   cin.ignore();
   cin.get(std[i].course,100);
   cout<<"Student Borthday     : "<<endl;;
   cout<<"Date  : ";
   cin.ignore();
   cin>>std[i].dob;
   cout<<"Month : ";
   cin.ignore();
   cin>>std[i].mob;
   cout<<"Year  : ";
   cin.ignore();
   cin>>std[i].yob;
   i++;
  }
so when the user have finish the input the data, it will automatic write to a file call "student_details.txt".
when the user want to display out the data that user input, the program can automatic read from the file "student_details.txt" and it will show the data in the screen with the function "dpl".
Code:
void dpl()
  {
   for(int a=1;a<=i;a++)
   {
     cout<<"Student Name     : "<<std[a].name<<endl;
     cout<<"Student ID       : "<<std[a].id<<endl;
     cout<<"Student IC       : "<<std[a].ic<<endl;
     cout<<"Student Gender   : "<<std[a].gender<<endl;
     cout<<"Student Course   : "<<std[a].course<<endl;
     cout<<"Student Birthday : "<<std[a].dob<<"/"<<std[a].mob<<"/"<<std[a].yob<<endl;
     cout<<"============================================="<<endl;
   }