VC中怎么读取.txt文件啊,和.dat和.bin的读取方式一样吗? 我知道.dat和.bin可以用fread来读取。 谢谢啦
解决方案 »
- 远程控制的问题,救急啊!!!!!
- 一个listctrl的的keydown的问题
- access中备注类型,在VC数据库编程中怎么处理??
- MFC中的D/V
- Send(Handle(w_emp), 277, 2, 0)是什么意思
- 如何得到ListView的标题栏数目并全部删除?
- 谁知道怎样从才可以使用(导出)DLL中带参数的函数?谢谢!error C2197: 'int (__stdcall *)(void)' : too many actual parameters
- 消息的传递问题 ----->>>
- server 端 IOCP 模型下 如何才能保证wsasend 的数据准确发送 ?
- 请问,一个关于ODBC编程的问题
- opengl贴图贴不上 找不到代码错误 请高手指点下
- 100分求概要设计、详细设计说明书模板及响应例子,多谢。
char buff[size];
fread(buff, size, 1, f);
fclose(f);
CFile file("yourfile.txt",CFile::modeRead);
char *pBuf;
int iLen=file.GetLength();
pBuf =new char[iLen+1];
file.Read(pBuf,iLen);
pBuf[iLen]=0;
file.Close();
MessageBox(pBuf);
HANDLE hFile;
hFile=CreateFile("2.txt",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
char ch[100];
DWORD dwReads;
ReadFile(hFile,ch,100,&dwReads,NULL);
CloseHandle(hFile);
ch[dwReads]=0;
MessageBox(ch);*
FILE *pFile=fopen("1.txt","rb");
char *pBuf;
fseek(pFile,0,SEEK_END);//移动文件指针到文件末尾
int len=ftell(pFile);//获取当前文件指针在文件中的偏移量,Gets the current position of a file pointer.offset
pBuf=new char[len];
rewind(pFile);//将指针移动到文件头,Repositions the file pointer to the beginning of a file
//也可以用fseek(pFile,0,SEEK_SET);
fread(pBuf,1,len,pFile);
pBuf[len]=0;
MessageBox(pBuf);
fclose(pFile); *