关于NULL
#include <stdio.h>#include <stdlib.h>
int main(int argc, char *argv[])
{
int ch;
FILE *fp;
if((fp==fopen(argv[1], "r"))==NULL)
{
printf("\n The file: %s can not be opened \n", argv[1]);
exit(1);
}
ch = fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
printf("argc is %d", argc);
fclose(fp);
return 0;
}
----------------------------------
程序运行后应该可以显示指定文件的内容。
如:009 filename.txt
编译出错:(我的编译器是DEV-C++)
8 F:\C\programe\009.c [Warning] comparison between pointer and integer
百度了,Google了,但是还是不明白,请教高手!
[[italic] 本帖最后由 deepseep 于 2007-12-10 22:00 编辑 [/italic]]