各位大侠小弟有一问题想问大家,就是我实时的数据想保存到文本文档中,现在有一个问题。
就是每次程序重新启动后,发现数据都不换行,而是覆盖了以前的数据。如何才能换行,保存所有的数据。代码如下:
static char *p = new char[20];
static char *p1 = new char[20];
static char *p2 = new char[20];
static DWORD dwWrites;
static DWORD dwWrites1;
static DWORD dwWrites2;
hFile=CreateFile("E:\\abc.txt",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);//
m_width=a/100;
sprintf(p, "%.2f\x20", m_width);
WriteFile(hFile, p, strlen(p), &dwWrites,NULL);
m_height1=b/100;
sprintf(p1, "%.2f\x20", m_height1);
WriteFile(hFile, p1, strlen(p1), &dwWrites1,NULL);
m_height2=c/10
sprintf(p2, "%.2f\r\n", m_height2);
WriteFile(hFile, p2, strlen(p2), &dwWrites2,NULL);
就是每次程序重新启动后,发现数据都不换行,而是覆盖了以前的数据。如何才能换行,保存所有的数据。代码如下:
static char *p = new char[20];
static char *p1 = new char[20];
static char *p2 = new char[20];
static DWORD dwWrites;
static DWORD dwWrites1;
static DWORD dwWrites2;
hFile=CreateFile("E:\\abc.txt",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);//
m_width=a/100;
sprintf(p, "%.2f\x20", m_width);
WriteFile(hFile, p, strlen(p), &dwWrites,NULL);
m_height1=b/100;
sprintf(p1, "%.2f\x20", m_height1);
WriteFile(hFile, p1, strlen(p1), &dwWrites1,NULL);
m_height2=c/10
sprintf(p2, "%.2f\r\n", m_height2);
WriteFile(hFile, p2, strlen(p2), &dwWrites2,NULL);
解决方案 »
- 哪位能给讲一讲32位程序和64位程序的本质差异?
- 如何在两个listview控件之间传递数据?
- 关于屏幕闪烁的问题?
- 问一个很弱的问题:EXE文件是否可以暴露其对外接口?
- 诸位做过在 vc的一个程序下嵌入 outlook控件,以便自己的程序方便的实现mail处理的功能吗?
- 我的程序应用了DLL,但是我怕DLL产生的错误使整个程序都崩溃,问一下一个DLL怎样才算安全可靠
- 如何刷新界面?
- 想开发shareware的请进
- 多线程调用Com的问题,未启动辅助线程,仅用到了invoke方法,程序就阻塞了
- 如何根据快捷方式文件去得到进程名?
- 用MSComm控件编写串口通信时,实现串口号选择的问题
- VC 6.0对话框资源中Dialog误删除之后怎么还原
每次写文件之前SetFilePointer(...FILE_END);设置文件指针都文件尾,然后再写