segmentation fault

why does this function create a segmentation fault when executed:

has this error to do with it:

databary.c:67: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  int menu(){
	int choise = 0, check = 0;
		while (check == 0){
		printf("choose an oprion by pressing the number, then press enter\n");
		printf("1:  add book\n");
		printf("2:  search book\n");
		printf("3:  check reservements\n");
		printf("4:  make reservement\n");
		printf("5:  exit program and save changes\n");
		check = 0;
		scanf("%d",choise);
		if (choise>0 && choise<6){
			check=1;
			return choise;
		}
	}
	return 0;
}
Because it expects (like the warning says) a pointer to int. So change it to

scanf("%d",&choise); // Note: &
thank you!!
Topic archived. No new replies allowed.