#include <stdio.h>
#include <stdlib.h>
int main()
{
int launchcode = rand() %25+1;
int code1;
int code2;
int code3;
int code4;
char buffer[20];
printf(" Hello commandor please input your first name only\n");
scanf("%s", &buffer);
printf("Access granted welcome commander %s\n Please enter four numbers between 1 and 25 these are your launch codes.\n If they match the world is yours\n ", &buffer);
printf("First number please\n");
scanf("%d",&code1);
if (code1 == launchcode)
{
printf("The world is yours\n");
goto programend;
}
else
if(code1 != launchcode)
{
printf("Launch code 1 failed\n");
}
printf("Second number\n");
scanf("%d", &code2);
if(code2 == launchcode)
{
printf("The world is yours\n");
goto programend;
}
else
if(code2 != launchcode)
{
printf("Launch code 2 failed\n");
}
printf("Third number\n");
scanf("%d", &code3);
if(code3 == launchcode)
{
printf("The world is yours\n");
goto programend;
}
else
if(code3 != launchcode)
{
printf("Launch code 3 failed\n");
}
printf("I know your happy its the last one fourth number please\n");
scanf("%d", code4);
if(code4 == launchcode)
{
printf("The world is yours\n");
goto programend;
}
else
if(code4 != launchcode)
{
printf("Launch code 4 failed\n");
}
printf("The launch code was %d\n", launchcode);
system("Pause");
return 0;
programend:
printf("All your launch codes have failed you are not the true commander. You fail");
system("Pause");
}
This is giving me a access violation error from my debugger I really have no idea whats wrong and for the most part it works.

New Topic/Question
Reply




MultiQuote





|