ok so im quite new to C and i am learning it atm, (cut me som slack). so im going thru the c for dummies book and came to the point of using scanf and printf and whas thinking to take the program one step futher. so i made it like so that if you answer correctly it will just to the next question but i had some minor bugs.
And i know 2+2=4 kinda thing but it is just not that easy for me :P hehe
Source code:
Code:
#include <stdio.h>
int main()
{
char name[20];
char color[20];
printf("What is your name?");
scanf("%s",name);
if (strcmp(name,"david") == 0);
else printf ("get away from the pc!");
printf("What is your favorite color?");
scanf("%s",color);
if (strcmp(color,"blue") == 0);
printf("%s’s favorite color is %s, oh i forgot... the password is david\n",name,color );
return(0);
}
And now the bugs
Code:
john@ubuntu:/home/prog/C$ ./safe
What is your name?idunno
get away from the pc!What is your favorite color?youarenotstopping
idunno’s favorite color is youarenotstopping, oh i forgot... the password is david
john@ubuntu:/home/prog/C$
The point is that if you answer wrong the program should end. now ive been thinking that is ther a way to make it show the text "get away from the computer" and then count down from 5 sec and close terminal ?

Any answer is welcome thank you