I'm new to C language and having this problem alot, the code compiles with no problems yet still get this message:
Segmentation faultwhen trying to execute my code on UNIX terminal. This is the code:
///MAIN FUNCTION///
int main() {
printf("==========================J.U.S.T=======================$
printf("Enter your option number:\n1- working with an existing f$
char choice[1];
scanf("%c",choice);
if(choice[0] == '1'){
printf("first choice");
}
else if(choice[0] =='2' ){
printf("Enter the following data one by one:");
char BookT[50],AUTHORn[50];long int ISBN;
printf("Book Title:");
scanf("%s",BookT);
// sleep(5);
printf("Author name:");
scanf("%s",AUTHORn);
// sleep(5);
printf("Book number:");
scanf("%d",ISBN);
// sleep(5);
printf("%s\n%s\n%d\n",BookT,AUTHORn,ISBN);
}
else printf("Wrong choice try again!!");
return 0;
}
I'm using Kali linux to compile the code.