portaldude
December 18th, 2008, 12:31 PM
Goodday everyone.
I recently took up learn the C programming language, using the excellent book "The C programming language". I am only a few pages in and have encountered following example
#include <stdio.h>
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
Courious as I am, I wanted to play around with the program a bit and such, I copied it, saved it in a .c file format and compiled, using the GCC compiler that came with my Ubuntu distrubution, using the command
gcc myfile.c
There after, I ran the program and to my big surprise, it started to behave bizzarly.
If I wrote something in the terminal window like "I am testing this program", the program would output "PPPPPPPPPPPPPPPPPPPPPPPPPP"(that exact output), or a long lines of blanks.
I tried the GCC compiler in Windows, and there it would output my input flawless.
Does anyone know what is going on? Is there a bug in the compiler?
I recently took up learn the C programming language, using the excellent book "The C programming language". I am only a few pages in and have encountered following example
#include <stdio.h>
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
Courious as I am, I wanted to play around with the program a bit and such, I copied it, saved it in a .c file format and compiled, using the GCC compiler that came with my Ubuntu distrubution, using the command
gcc myfile.c
There after, I ran the program and to my big surprise, it started to behave bizzarly.
If I wrote something in the terminal window like "I am testing this program", the program would output "PPPPPPPPPPPPPPPPPPPPPPPPPP"(that exact output), or a long lines of blanks.
I tried the GCC compiler in Windows, and there it would output my input flawless.
Does anyone know what is going on? Is there a bug in the compiler?