Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354098

Summary: fflush(stdout) needed for printf() and scanf() functions
Product: [Tools] CDT Reporter: stephen weber <stephen_weber>
Component: cdt-otherAssignee: Project Inbox <cdt-core-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: enhancement    
Priority: P3 CC: yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

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.