Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354098 - fflush(stdout) needed for printf() and scanf() functions
Summary: fflush(stdout) needed for printf() and scanf() functions
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-other (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-07 16:22 EDT by stephen weber CLA
Modified: 2020-09-04 15:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stephen weber CLA 2011-08-07 16:22:56 EDT
Build Identifier: Helios 3.6.1

Given the original program from "C Programming :A Modern Approach" using printf and scanf , all the requests for inputs from scanf's need to be added before all of the printf's are dumped to the console in Eclipse. 
 The obvious solution is to use fflush as for example bug code Bug 173732 wrote 4 years ago. 
Hoping this gnat detail can be fixed some day ;)
..........................



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

int main(void) {

	int num1,denom1,num2,denom2,result_num,result_denom;


 printf ("Enter first fraction :");


 scanf("%d/%d",&num1,&denom1);

 printf("Enter second fraction :");
 
 scanf("%d/%d",&num2,&denom2);

result_num=num1*denom2+num2*denom1;
result_denom=denom1*denom2;
printf("The sum is %d/%d\n",result_num,result_denom);
 

	return 0;
}


output "
3/4
4/5
Enter First Fraction :Enter Second Fraction :The Sum is 12/20


-------------
needs:




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

int main(void) {

	int num1,denom1,num2,denom2,result_num,result_denom;


 printf ("Enter first fraction :");
 fflush(stdout);

 scanf("%d/%d",&num1,&denom1);

 printf("Enter second fraction :");
 fflush(stdout);
 scanf("%d/%d",&num2,&denom2);

result_num=num1*denom2+num2*denom1;
result_denom=denom1*denom2;
printf("The sum is %d/%d\n",result_num,result_denom);
fflush(stdout);

	return 0;
}


output:
Enter First Fraction:3/4
Enter Second Fraction :4/5
The Sum is 12/20

Reproducible: Always

Steps to Reproduce:
1. See Detail Short Codes
2.
3.