2

I have installed MinGW on netbeans for C and C++ programming.
Here is a simple code that I am trying to run on netbeans :

#include <stdio.h>
int main(int argc, char** argv) {
    printf("Inside Main...\n");
    int n;
    printf("Enter : ");
    scanf("%d", &n);  // When I remove this line, it is working.
    printf("You have entered %d.", n);
    return (1);
}

Whenever I try to access any value from netbeans console, I don't see anything.

Output with scanf(...)

enter image description here

Output without scanf(...)

enter image description here

And if I try to run these code from cmd, all are working

afzalex
  • 8,598
  • 2
  • 34
  • 61

2 Answers2

2

for scanf() you must use Netbeans External Terminal !

enter image description here

Normal Run

enter image description here

You can also use Netbeans Standard Output !
But this is more misleading.
While you see an empty Terminal do input 123

enter image description here

after hit enter , you get the output all at once .

enter image description here

moskito-x
  • 11,832
  • 5
  • 47
  • 60
1

I had the same issue while running a CPP program.External output didn't helped me. I set the console type to Standard output and it solved the issue.

Right Click cpp Application-->properties-->run--->Consoletype to standard output