segmentation fault in C during scanf -


i trying scan in integer use program. program gives me segmentation fault during compilation section giving me error:

int main(void) {     int totalheight=0, floorwidth=0, amountofstories, amountwindowfortop, amountwindowformiddle, amountwindowforbottom, windowheight, middlewindowwidth, topwindowwidth, bottomwindowwidth, minimumheight, minimumwidth;      char topfloorwindowcontent, middlefloorwindowcontent, bottomfloorwindowcontent, windowborder, floorborder;      int tempmax;      printf("please enter how many stories building have: ");     scanf("%d",&amountofstories);     minimumheight=amountofstories*6+1;     while((totalheight<minimumheight)||((totalheight%amountofstories)!=1))     {         printf("please enter totalheight (minimum %d): ",minimumheight);         scanf("%d",&totalheight);     }     printf("please enter how many window building have top floor: ");     scanf("%d",amountwindowfortop);     printf("please enter how many window building have middle floors: "); 

now program after compile runs scanf on amoutwindowfortop after enter in value gives me segmentation fault have no idea why. because not using pointers why giving me error?everything seemed in order me output

please enter how many stories building have: 5 please enter totalheight (minimum 31): 31 please enter how many window building have top floor: 2 segmentation fault 

you missed &,

line

scanf("%d",amountwindowfortop); 

should be

scanf("%d", &amountwindowfortop); //---------^ 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -