#include<iostream.h> #include<conio.h> #include<fstream.h> #include<string.h> void main(){ struct quiz//structure for storing questions { char ques[200]; char op1[30]; char op2[30]; char op3[30]; char op4[30]; char z[2]; }q; ofstream outf("item.csv"); cout<<"enter question :"<<endl; cin>>q.ques; outf<<q.ques<<"\n"; cout<<"enter option A :"<<endl; cin>>q.op1; outf<<q.op1<<" "; cout<<"enter option B :"<<endl; cin>>q.op2; outf<<q.op2<<" "; cout<<"enter option C:"<<endl; cin>>q.op3; outf<<q.op3<<" "; cout<<"enter option D :"<<endl; cin>>q.op4; outf<<q.op4<<" "; cout<<"enter correct option :"<<endl; cin>>q.z; outf<<q.z<<endl; outf.close();//end of file for storing in file ifstream inf("item.csv");//opening file for reading inf>>q.ques; inf>>q.op1; inf>>q.op2; inf>>q.op3; inf>>q.z; cout<<endl; cout<<"question"<<endl<<q.ques<<endl; cout<<q.op1<<" "<<q.op2<<" "<<q.op3<<" "<<q.op4<<endl; cout<<"correct ansrer no"<<" "<<q.z<<endl; getch(); inf.close();//closing file }//end of main function
cin
cin.getline
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)