NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Simple C code not showing output

 
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users
View previous topic :: View next topic  
Author Message
ayanhore18



Joined: 05 Mar 2017
Posts: 1
Location: India

PostPosted: Sun Mar 05, 2017 6:14 am    Post subject: Simple C code not showing output Reply with quote

Hello there,
I have coded in C before but using NetBeans for the first time.The build is successful ,so is compilation,and using MinGW ,but no output is shown for a simple C code even.I wrote the following in main.c within source files folder.

#include<stdio.h>
#include<stdlib.h>

int main()
{
int str;
printf("\nEnter a value :");
str=getchar();

printf( "\nYou entered: ");
putchar(str);

return(0);
}

Please help.
Thanks in advance.
P.S:Standard output isn't working but same code is doing fine in external terminal via command window
Back to top
waynehamberg



Joined: 28 Sep 2017
Posts: 9

PostPosted: Fri Oct 13, 2017 8:23 pm    Post subject: fflush(stdout) Reply with quote

Add fflush(stdout) after your printf statements. Printf doesn't always flush the buffer and sometimes you need to do this manually.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo