I wanted to code something for write to fstream but my void function works fist what I wanted but next after used do while statement it doesn't do what did before it skips the name input then goes to output with puts(), even cout can't solve it how do i solve and any advice on tools i am using i appreciate your time to read this Code :
class student
{
public:
void ask()
{
std::cout<<"Hello Sir whats your name"<<std::endl;
gets(name);
std::cout<<"What do you like"<<std::endl;
gets(item);
std::cout<<"How old are you"<<std::endl;
gets(age);
std::cout<<"Done..."<<std::endl;
}
private:
char name[20];
char item[20];
char age[4];
};
int main()
{
student st1;
char c[6];
char g[10];
char yes;
do
{
st1.ask();
std::cout<<"again...?"<<std::endl;
std::cin>>yes;
}
while(yes=='Y' || yes=='y');
return 0;
}