| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:如何查看文件指针所指文件的内容
只看楼主 加入收藏
guaishou369
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2005-12-18
收藏
 问题点数:0 回复次数:1 
如何查看文件指针所指文件的内容
当用文件指针(*FILE)指向一个文件时,如何查看该文件的内容?

[此贴子已经被作者于2005-12-21 19:04:39编辑过]


搜索更多相关主题的帖子: 指针 所指 文件 
2005-12-21 19:03
新坏男人
Rank: 1
等 级:新手上路
威 望:1
帖 子:38
专家分:0
注 册:2005-12-7
收藏
得分:0 

#include <stdio.h>

void main()
{
FILE *fp;
char buf[33];

fp=fopen("d:\\test1.txt","r"); //文件所在的路径
if(fp!=NULL)
{
int len;
do
{
len=fread(buf,sizeof(char),32,fp);
buf[len]='\0';
printf("%s\n",buf);
}while(len==32);
fclose(fp);
}
else
{
printf("open error!");
}
}


/UploadFile/2005-11/2005112317153975.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www./UploadFile/2005-11/2005112317153975.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-12-21 19:12
快速回复:如何查看文件指针所指文件的内容
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015192 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved