473,503 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

when i am running the C prog after compile, it is not showing the result.

3 New Member
#include <stdio.h>

void main()
{
int a;
printf("Enter value of a = ");
scanf("%d\n",&a);
a = a + 10;
printf("The final value of a is %d",a);
}

when i am running this simple program it stops showing result. It executes only upto 'scanf'... After entering the 'a' value it is not showing the final result value.(i.e. 56, if a is entered 46) and i have to stop it forcefully from 'windows task manager'.

why it does happen and what is the solution?

Thank you.
Dec 11 '10 #1
5 2785
weaknessforcats
9,208 Recognized Expert Moderator Expert
It probably does show your result. However, since you have no code to pause the program after the printf, your result is displayed for only a split-second.
Dec 11 '10 #2
donbock
2,426 Recognized Expert Top Contributor
It is common for stdout to be a buffered output. This means that characters written to stdout are held in an internal buffer until either a newline is written to stdout or fflush is called.

Terminate your format string with a newline.
Dec 12 '10 #3
nandish ptl
3 New Member
how can i pause the program to display result..?

i tried with different simple codes but the problem remains same. For exmple
i wrote the following code...

#include <stdio.h>

void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
}

when i am running the code black screen appear for a moment and angain main (blue) screen appears..

what is the solution?

Thank you
Dec 12 '10 #4
nandish ptl
3 New Member
i terminated the format string with new line.. but it didnt work.
Dec 12 '10 #5
AdrianH
1,251 Recognized Expert Top Contributor
the simplest way is:

Expand|Select|Wrap|Line Numbers
  1. printf("Press enter to continue...");
  2. fflush(stdout);
  3. scanf("%*s");
  4.  
Dec 12 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1126
by: Chris | last post by:
hello, I have a small module which only contains some utility functions. when running this standalone I would like to show the module docs and each function docs, as if doing import M help(M)...
2
1175
by: Giovanni | last post by:
Hello, I was playing with Visual C# Compiler version 8.00.40607.42. I made a simple example to test if the compiler was working fine. here is the code: using System; public class Start{
0
1049
by: Peter Row | last post by:
Hi, I have written a DLL that implements IHttpHandler methods, i.e GetHandler, ProcessRequest etc... I also automatically login visitors to the site as an appropriate guest (based on browser...
0
1001
by: Michael Groeger | last post by:
Hi, we are currently in development phase of a web application. We have a custom base page and set the Web.config attribute <pages pageBaseType=""/> correctly. As long as we are running only one...
4
1910
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
2
4886
by: Oenone | last post by:
I am developing an assembly that can be used either by a Windows Forms application or from within an ASP.NET web site. When running within the Forms app, I can break into the code while it is...
0
1817
by: Uma | last post by:
Dear all, I have a problem while running a smart client application which was installed through CD-ROM. After installing the smart client setup the application is running properly. When running...
5
8944
by: =?Utf-8?B?cnZhbmdlbGRyb3A=?= | last post by:
Hello, I have a problem with our OnlineBackupService.exe. This is a Windows Service which is built in .Net 1.1 and basically grabs files from the file system and will try to upload them using...
8
9464
by: tvnaidu | last post by:
I am running prog with GDB - throws SIG32, why? @localhost config]# gdb prog GNU gdb Red Hat Linux (5.3.90-0.20030710.40rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software,...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.