向文件写字符串的程序
怎样用从c++ 写个向文件写字符串的程序
比如 log( "content ");
就向log.txt写入
[解决办法]
FILE *fp=fopen( "log.txt ", "w ");
if(fp)
{
fprintf(fp, "%s ", "Hello ");
}
else
printf( "文件打开错误!÷ ");
fclose(fp);
[解决办法]
FILE* fp = fopen( "c:\\log.txt ", "a+ " );
if( fp == NULL ) return;
strcpy(sz, _T( "content "));
fwrite( sz, sizeof( char ), strlen(sz), fp );
fclose(fp);