I am working my way through section 1.5.1 of K&R C second addition (which is 89C I believe). This is the program that is for "file copying."
I am using the latest version of debian and the gcc from the standard repository. Although, I modified stty so it sends the EOF signal. And I am writing it for C99 rather than watch the compiler complain.
My Code reads:
#include<studio.h>
void main ()
{
int c;
c=getchar();
while(c != EOF) {
putchar(c);
c = getchar();
}
}
The output is a flashing cursor that allows input.
I write: "The dog is black and white." Or any length of string. Nothing happens
Upon pressing return the output is the entire string.
The EOF signal exits the program.
I have read c99 compliant references and it appears to me it should output a single letter rather than the entire string. Can anyone verify that for me or offer some insight as to why I'm getting such bizarre behavior?
I am using the latest version of debian and the gcc from the standard repository. Although, I modified stty so it sends the EOF signal. And I am writing it for C99 rather than watch the compiler complain.
My Code reads:
#include<studio.h>
void main ()
{
int c;
c=getchar();
while(c != EOF) {
putchar(c);
c = getchar();
}
}
The output is a flashing cursor that allows input.
I write: "The dog is black and white." Or any length of string. Nothing happens
Upon pressing return the output is the entire string.
The EOF signal exits the program.
I have read c99 compliant references and it appears to me it should output a single letter rather than the entire string. Can anyone verify that for me or offer some insight as to why I'm getting such bizarre behavior?