stdout,stdin浅析
1005 ワード
《The C programming Language》 stdin,stdout
"The file pointers stdin and stdout are objects of type FILE *. They are constants, however, not variables, so it is not possible to assign to them."
stdout printf fprintf stdout , ( ) , , . C stdout 。
#include <stdio.h>
int main(int argc,char *argv[])
{
FILE *ifile;
//FILE *ofile;
char c;
if(argc <= 1)
{
return 0;
}
else
{
if((ifile = fopen(*++argv,"r")) == NULL)
{
printf("cat the file %s erro.
",*argv);
return 0;
}
else
{
while((c = getc(ifile)) != EOF)
{
putc(c,stdout);
}
}
}
return 0;
}