Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void if_correct()
- {
- int menu_keuze;
- printf("What would you like to do?\n\n");
- printf("1: Dollar To Euro\t 2:Launch A Missile\t 3:Log Out\n");
- scanf("%i",&menu_keuze);
- printf("\n");
- if(menu_keuze==1)
- {
- float dollar=1.47;
- float omrekenen;
- float totaal;
- printf("Hoeveel dollars wilt u omrekenen?\n");
- scanf("%f",&omrekenen);
- totaal=omrekenen/dollar;
- printf("%.2f\n\n",totaal);
- if_correct();
- }
- else if(menu_keuze==2)
- {
- int start_nummer;
- printf("Count down from?\n");
- scanf("%i",&start_nummer);
- printf("\n");
- while(start_nummer!=0)
- {
- printf("%i seconds till launch!\n\n",start_nummer);
- start_nummer--;
- }
- printf("Take cover! Takeoff! BoOoOoOoOom!\n\n");
- if_correct();
- }
- else if(menu_keuze==3)
- {
- main();
- }
- else if(menu_keuze!=1||2||3)
- {
- printf("Enter a valid menu option\n!");
- if_correct();
- }
- }
- int main()
- {
- char username[10];
- char user[10];
- char password[10];
- char pass[10];
- int times=0;
- int end=0;
- int i=0;
- int settings_set;
- while((end==0)&&(times < 3))
- {
- printf("nieuwe username:\n");
- scanf("%s",username);
- printf("\n");
- printf("nieuwe password:\n");
- scanf("%s",password);
- settings_set=1;
- printf("\n");
- printf("username:\n");
- scanf("%s",user);
- printf("\n");
- printf("password:\n");
- scanf("%s",pass);
- printf("\n");
- //printf("%s %s %s %s\n",username,user,password,pass); <-- controleert of de waarden goed worden opgenomen door scanf
- if(strcmp(username,user)==0 && strcmp(password,pass)==0)
- {
- printf("correct\n\n");
- end++;
- if_correct(); /*Roept if_correct()*/
- }
- else if(strcmp(username,user)!=0 || strcmp(password,pass)!=0)
- {
- printf("fout\n");
- times++;
- if(times==3)
- {
- printf("U heeft 3 maal de verkeerde gegevens ingevuld, herstart het programma!\n");
- }
- else /* if(times!=3) <-- optioneel */
- {
- printf("Dit is maal %i dat u verkeerde gegevens ingeeft, na de 3de keer moet u het programma herstarten!\n\n",times);
- }
- }
- else /*dit moet niet kunnen gebeuren*/
- {
- printf("An anknown error has occurred, try again please!\n");
- main();
- }
- } // einde while
- return(0);
- }
Add Comment
Please, Sign In to add comment