Member Avatar for xEffrego

My code is this atm:

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

int main(int argc, char *argv[]){

   int a,b,c;
   int swap;

   printf("Enter 3 Numbers (# # #):");
   scanf("%d %d %d", &a,&b,&c);

   //does all its computing, to see which one is biggest.
   return EXIT_SUCCESS;
}

The result when i run it in eclipse is that, I have to put in 3 numbers first, THEN it says "Enter 3 Numbers (# # #):"
(So it stays blank at start of program)
I remember I had this problem a long time ago but I have switched back to eclipse now and somehow this happens. :/
Thanks in adance.

add fflush(stdout) after the printf() statement to force the os to output the text

Setbuffer to null at begining of main function

int main(){
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);

Follow the Dragon's suggestion. Ignore SRE93's

Doesn't SRE93's suggestion solve the problem on *nix?

Member Avatar for xEffrego

Hmm, well I have switched to code::blocks instead for now, I'm afraid I might forget to remove those statements and I will get marked down for it(since I am supposed to only use code that I have learnt during the course I am doing), anyway maybe I'll give Eclipse a go some other day. Though also which Visual Studio can be used for C Programming?

Then try adding '\n' to the end of your printf() message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.