segmentation fault in C during scanf

后端 未结 4 1068
忘了有多久
忘了有多久 2020-12-12 08:18

I am trying to scan in an integer to use for my program. However my program gives me segmentation fault during compilation this is the section that is giving me the error:

相关标签:
4条回答
  • 2020-12-12 08:41

    You missed & in

    scanf("%d",amountWindowForTop);
    

    this must be

    scanf("%d",&amountWindowForTop);
    

    Cause of error is & is called address of operator so missing it in scanf means where are you put your value means address is required because it specify the address of variable where we have to keep the value. segmentation fault error is generally we get whenever their is any problem related with address. Hope useful for you.

    0 讨论(0)
  • 2020-12-12 08:42

    You missed & in

     scanf("%d", amountWindowForTop);  
                ^Place & operator 
    
    0 讨论(0)
  • 2020-12-12 08:50

    You are missing the &

    scanf("%d",&amountWindowForTop);
               ^
    
    0 讨论(0)
  • 2020-12-12 09:06

    You missed &,

    Line

    scanf("%d",amountWindowForTop);
    

    should be

    scanf("%d", &amountWindowForTop);
    //---------^
    
    0 讨论(0)
提交回复
热议问题