#include<iostream.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
class qa
{ char question[35];
char option[4][20];
int ans; //correct option no (eg 0 1 2 3)
public:
void getques()
{ gets(question);
cout<<endl;
}
void getopts()
{cin>>option[0]>>option[1]>>option[2]>>option[3];
}
void getans()
{ cin>>ans;
}
};
void main()
{ int n;
qa q;
fstream file1;
file1.open("questions.dat",ios::out);
cout<<"\n Enter the limit of questions " <<endl;
cin>>n;
for(int i=0;i<n;i++)
{ cout<<"Enter the question" <<endl;
q.getques();
cout<<"enter the four options " <<endl;
q.getopts();
cout<<"Enter the answer for the respective questions " <<endl;
q.getans();
file1.write((char*)&q,sizeof(q));
}
file1.close();
}
The above is a quiz program..
it executes perfectly ....the problem i am facing is that ..which entering the questions to the binary file ...when it asks for options ...and when i am entering the options ...
suppose one of the options is with 2 words.. like " jovial bone" ..then it takes "jovial " as 1 option and "bone" as another...
how do i make "jovial bone" as 1 option ???
please reply ASAP ...thanksss!!!