A闪的 BLOG 技术与人文
引用标准库中的stdio.h其中包含了磁盘流操作的相关函数,代码如下: #include <stdio.h>
int main(int argc, const char * argv[]) {
FILE *fp;
char ch;
if((fp=fopen("/Volumes/Macintosh HD 2 1/mymac/macframework/cdemo2/cdemo2/a.txt","rt"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
ch=fgetc(fp);
while (ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
return 0;
}