there is no output and no errors at all what would be wrong ?Code:#include <stdio.h> /* copy input to output; 1st version */ main() { int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } }
there is no output and no errors at all what would be wrong ?Code:#include <stdio.h> /* copy input to output; 1st version */ main() { int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } }
getchar() buffers input, and waits until a newline is encountered, before returning the first character typed.
The net effect is that it will appear as if your program waits for a line before echoing that line.
What do you mean "no output"
Did you type anything in?
Blue is what I typed, the rest is what the program printed.Code:$ gcc bar.c $ ./a.out hello world hello world hey hey it works it works
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I totally misunderstood copying input to output, I thought it would print out the code.
Thanks you Salem and grumpy!
What? You thought that code was a quine????? Not even close.