john woolstock
john woolstock

Reputation: 187

Unable to find any valid shell. Required for execution in an external terminal

so I'm currently running my C program in NetBeans IDE 8.1, but as soon as I tried using the scanf function, I began running into issues. I have MinGW download and have added C:\MinGW\bin; to my path environment variable. I looked up and found that I should be running external terminal to use scanf but I am receiving this error. Does anyone have any idea how to fix this. I'm pretty new to C and this IDE so simpler instructions would be appreciated. Here is the code:

#include <stdio.h>

int main()
{
    int int1, sum, int2;
      printf("Enter\n");
      scanf("%d", int1);
      printf("Enter\n");
      scanf("%d", int2);
      sum = int1 + int2;
      printf("sum is %d", sum);

      return 0;

}

Upvotes: 0

Views: 220

Answers (1)

lost_in_the_source
lost_in_the_source

Reputation: 11237

You need to pass an int *, not an int into scanf. This is because scanf must fill in each argument in the variable argument list. Your code should be

int main()
{
    int a, b;
    printf("Enter first number\n");
    scanf("%d", &a);

    printf("Enter second number\n");
    scanf("%d", &b);

    printf("sum is %d\n", a + b);

    return 0;
}

Upvotes: 2

Related Questions