I've only been experimenting with programming for about 3 days, so please be kind. I am just playing around trying to make a program to learn stuff, but this doesn't do what I want it to. Can someone point me in the right direction, of what I am doing wrong?
I basically want the user to input the correct answer before moving on.
Sorry if this seems stupid.
Code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
// My first attempt at a program
char ans1[6]="";
char ans2[6]="";
cout<<"Here is my first program. Answers are one word, and lowercase.\n Enjoy!",endl;
cout<<" \n";
cin.get();
do{
cout<<"What has a bed, but doesn't sleep?\n A mouth, but doesn't talk? \n", endl;
cout<<"and a head, but doesn't think?\n", endl;
cout<<"\n\n";
cout<< "Answer: ";
cin>> ans1;
if (ans1 != " river ")
cout<<"\nPlease Try Again\n", endl;
}
while (ans1 != " river ") ;
cout<<"CORRECT!", endl;
cin.get();
//Next question
do{
cout<<"I can only do my job when my head is struck,\n","What am I?\n", endl;
cout<<"Answer: " ;
cin.getline(ans2,10);
if (ans2 != "match")
cout<<"Please Try Again\n", endl; }
while(!(ans2 == "match"));
cout<<"CORRECT!", endl;
cin.get();
cout<<"Thank you for playing!", endl;
cin.get();
}
Thanks.