首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

遇到fopen的一个有关问题,紧

2012-02-29 
遇到fopen的一个问题,紧急AnsiStringstryearFILE*outfstr1 abc if(outffopen( e:\\a.txt , a )

遇到fopen的一个问题,紧急
AnsiString   stryear;
FILE   *outf;
str1= "abc ";
if   (outf=   fopen( "e:\\a.txt ", "a "))
{
                    fprintf(outf, "%s ",str1);  
                    fclose(outf);
}
以上是成功的,但是把 "e:\\a.txt "换成testlog时,就报错.
如下:
AnsiString   stryear,testlog;
FILE   *outf;
str1= "abc ";
testlog= "e:\\yw.txt ";
if   (outf=   fopen(testlog, "a "))
{
                    fprintf(outf, "%s ",str1);  
                    fclose(outf);
}


[解决办法]
testlog
改为 testlog.c_str()
[解决办法]
FILE *fopen(const char *filename, const char *mode);

fopen 函数的参数只能是 char*
所以必须把 AnsiString 做个转换

热点排行