读入二进制文件,并改变其中一个字节 用cfile类,读入data.dat把第八个字节ascii码+1后用AfxMessageBox()输出。cfile类不会用啊,msdn看得稀里糊涂。要是能看到一个例子就好了? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CFile file;char str[8];if(!file.Open(data.dat,CFile::modeRead | CFile::typeBinary)){ file.Open(str,sizeof(str)); file.Close();}else MessageBox("Can not open file!")CString strr = str;用strr.Find()找出第八个就可以了! void CXm9Dlg::OnButton1() { CFile f1;unsigned int ch=0;CString str;f1.Open("C:\\data.dat",CFile::modeRead|CFile::typeBinary);void *p=GlobalAlloc(GMEM_ZEROINIT,1);if(p==NULL) AfxMessageBox(_T("Failed to Allocat Memory")); while(f1.GetPosition()!=f1.GetLength()){ for(int x=0; x<8; x++)f1.Read(p,1);}ch=*((int *)p);ch++;str.Format("%d",ch);AfxMessageBox(str);f1.Close();GlobalFree(p);} 关于串口通信中 字节设置问题 从别处复制过来的图片,放在自己的程序里像素就变低了,没有原来的图片好看了。请大虾们指教! 无法解析的外部符号 图片处理的问题 loadbitmap失败,getlasterr是 87(参数不正确),郁闷 菜鸟入门问题,跪求高手帮助 CRecordSet里面修改值的问题 苦恼:如何在自绘的ListBox控件中同时实现垂直滚动条和多列显示?同时还能任意改变每个选项矩形的大小? 谁能告诉我这条题说什么?请选出答案,并说说相关的知识,谢谢! 给文件改名的API函数是什么?该用什么方法呢? ------ 请大家帮帮忙忙,取鼠标点处的亮度值!!!
char str[8];
if(!file.Open(data.dat,CFile::modeRead | CFile::typeBinary))
{
file.Open(str,sizeof(str));
file.Close();
}
else
MessageBox("Can not open file!")CString strr = str;
用strr.Find()找出第八个就可以了!
{ CFile f1;
unsigned int ch=0;CString str;f1.Open("C:\\data.dat",CFile::modeRead|CFile::typeBinary);void *p=GlobalAlloc(GMEM_ZEROINIT,1);
if(p==NULL)
AfxMessageBox(_T("Failed to Allocat Memory")); while(f1.GetPosition()!=f1.GetLength())
{
for(int x=0; x<8; x++)
f1.Read(p,1);
}ch=*((int *)p);
ch++;str.Format("%d",ch);
AfxMessageBox(str);
f1.Close();
GlobalFree(p);
}