Hi.
I'm doing an assingment for college but currently stuck on an IF staement within my program.
Basicaly instead of running the IF the staement the program seems to ignore it and go straight to the end of the program (Press any key to continue).
It's fine up until the first part of the IF staement bu then on key press the program quits.
I'm very new to C so appolgies if the program is a bit crappy
Any ideas? Cheers.
I'm doing an assingment for college but currently stuck on an IF staement within my program.
Basicaly instead of running the IF the staement the program seems to ignore it and go straight to the end of the program (Press any key to continue).
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char surname[30];
char initial[1];
char dob[8];
int choice;
printf("Please enter your surname: ");
scanf("%s", surname);
printf("Please enter your initial: ");
scanf("%s", initial);
printf("Please enter your date of birth in the DD/MM/YYYY format: ");
scanf("%d", dob);
system("cls");
printf("1 - Arithmetic \n");
printf("2 - Conversion \n");
printf("3 - Result \n");
printf("Please choose a number to continue: ");
scanf("%d",choice);
if(choice==1)
{
system ("cls");
printf("You chose 1");
}
else if(choice==2)
{
system ("cls");
printf("You chose 2");
}
return(0);
}
It's fine up until the first part of the IF staement bu then on key press the program quits.
I'm very new to C so appolgies if the program is a bit crappy
Any ideas? Cheers.