我把程序嵌入后,有编译错误.
于是将代码改为:
FILE file;
file=fopen("c:\\test.txt","r");
if
( file == NULL )
{
//没有创建文件,则创建文件
file=fopen("c:\test.txt","w");
//写入数据
file.write (strtemp);
fclose(file);
}
else
{
//表示创建了,则关闭后,在用追加方式写入
fclose(file);
file=fopen("c:\test.txt","a");
//写入数据
file.write (strtemp);
fclose(file);
}
发现还有编译错误
错误如下:
--------------------Configuration: CommWizard - Win32 Debug--------------------
Compiling...
CommWizardDlg.cpp
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(294) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct _iobuf *' (or there is no acceptable conversion)
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(295) : error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'struct _iobuf' (or there is no acceptable conversion)
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(298) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct _iobuf *' (or there is no acceptable conversion)
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(300) : error C2039: 'write' : is not a member of '_iobuf'
d:\microsoft visual studio\vc98\include\mbstring.h(92) : see declaration of '_iobuf'
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(301) : error C2664: 'fclose' : cannot convert parameter 1 from 'struct _iobuf' to 'struct _iobuf *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(306) : error C2664: 'fclose' : cannot convert parameter 1 from 'struct _iobuf' to 'struct _iobuf *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(307) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct _iobuf *' (or there is no acceptable conversion)
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(309) : error C2039: 'write' : is not a member of '_iobuf'
d:\microsoft visual studio\vc98\include\mbstring.h(92) : see declaration of '_iobuf'
E:\激光器驱动\温控电路相关资料\串口精灵源代码\CommWizardDlg.cpp(310) : error C2664: 'fclose' : cannot convert parameter 1 from 'struct _iobuf' to 'struct _iobuf *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.
CommWizard.exe - 1 error(s), 0 warning(s)
敬请修改