programing

scanf에서 솔루션 세그먼트 결함의 경우

minecode 2022. 10. 11. 21:26
반응형

scanf에서 솔루션 세그먼트 결함의 경우

#include <stdio.h>
#include <math.h>

int main() {
    int a;
    int b;
    printf("enter a");
    scanf("%d",& a);
    printf("enter b");
    scanf("%d",b);
    int sum = a+b;
    printf("sum is: %d");
    returno;
 }

주요 부분은

int a;
int b;
...
scanf("%d", &a);  //
scanf("%d", &b);  // the second parameter should be the address of b
...
return 0;

언급URL : https://stackoverflow.com/questions/73597319/for-solution-segment-fault-in-scanf

반응형