Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programs with the scanf not working properly in NetBeans

Tags:

c

netbeans

scanf

I've installed NetBeans 7.0.1 today When I try to execute C program with "scanf" in it it's giving strange errors

This is what I wrote:

Program

It keeps on running until I enter something in the output console. enter image description here

After entering its shows the printf statement and shows "RUN FAILED"

enter image description here

Can anybody tell me what should I do to make this right?

like image 904
Naresh Avatar asked Feb 02 '12 17:02

Naresh


2 Answers

Yes, I have same problem with you, and the solutions in answers are not working on my machine. After searching, I understand that this problem is about Netbean's internal terminal/console section. The internal console is not able to run scanf function. So use external terminal for your project. To do this:

  • first right click on your project, and select properties.
  • In that window select "Run" tab at the bottom.
  • in there, there is "Console Type", change this console type from "internal terminal" to "external terminal".

That is all.

like image 137
yasedox Avatar answered Sep 17 '22 08:09

yasedox


Your printf is not getting flushed so it is not showing until the program ends.

You are not returning a value from main() explicitly, so the result of scanf() is being returned, which is 1 which is interpreted as program failure.

like image 29
antlersoft Avatar answered Sep 19 '22 08:09

antlersoft