1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <stdio.h>
int main(int argc, char **argv)
{
FILE *f;
if(argc>1){
char buf[256];
sprintf(buf,"%s/%s",getenv("PWD"),argv[1]);
f=fopen(buf,"r");
}
else f=stdin;
setvbuf(stdin,NULL,_IONBF,0);
setvbuf(stdout,NULL,_IONBF,0);
char c;
printf("-- reading from file byte by byte --\n\n");
while(fread(&c,1,1,f))
{
printf("%c",c);
}
printf("\n-- no more data on this file --\n");
return 0;
}
|