Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to save the full output of the below C program in a .txt file.

C
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;

printf("Enter two numbers to add\n");
scanf("%d%d",&a,&b);

c = a + b;

printf("Sum of entered numbers = %d\n",c);
getch();

}


I used the following commands in cmd prompt. But it just shows the printf value alone and not save the scanf value(the keyboard inserted value).

C:\Programs\Ramkumar>sample.exe /all > file.txt


Can anyone provide me the command for the full output to save in txt file.

Thanks in advance.
Posted
Comments
chandanadhikari 20-Mar-14 11:45am    
may we know what are you trying to achieve here ?
Rage 21-Mar-14 8:12am    
Why are you not saving the values in file.txt directly in the sample.exe file ?
Mohibur Rashid 21-Mar-14 9:03am    
print the inputted value before printing calculated value
CHill60 23-Mar-14 14:33pm    
Virtual 5! The simplest solutions are often the best :-)
Mohibur Rashid 24-Mar-14 5:24am    
:).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900