Save this file as Test.c
Compile it and it should output the source code itself. It does nothing clever, just reads test.c and prints it.
#include <stdio.h>
main()
{
FILE *m;
char c;
m=fopen("test.c","r");
while(1)
{
c=getc(m);
if(c==EOF)
{
break;
}
printf("%c",c);
}
printf("\n");
fclose(m);
return 0;
}
Compile it and it should output the source code itself. It does nothing clever, just reads test.c and prints it.
#include <stdio.h>
main()
{
FILE *m;
char c;
m=fopen("test.c","r");
while(1)
{
c=getc(m);
if(c==EOF)
{
break;
}
printf("%c",c);
}
printf("\n");
fclose(m);
return 0;
}
The #include <stdio.h> does not show in my output because the screen does not fit it in. It scrolls up. Remove the 3 blank lines in the program code and it should show.
No comments:
Post a Comment