VC MFC 里怎么生成一个文件?

来源:百度知道 编辑:UC知道 时间:2024/06/30 21:40:57
如题,
在C:\处生成一个1.txt的文件里面内容为123456

ok?

void sfa(char * str)//参数是要写入文件的内容
{
CStdioFile csf;
csf.Open((LPCTSTR)"c:\\1.txt", CStdioFile::modeReadWrite, 0);
csf.WriteString((LPCTSTR)str);
csf.Flush();
csf.Close();
return;
}

HANDLE hFile = CreateFile("c:\\1.txt", // file to open
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // default security
CREATE_ALWAYS, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template

if ( INVALID_HANDLE_VALUE == hFile )
{
return 0;
}

DWORD dwWrite = 0;
WriteFile( hFile, "sdf", 3, &dwWrite, NULL );

CloseHandle( hFile );

char fn[20];
FILE* stream;
a=1;
b=123456;
void ConvertCString(CString str,char *buffer,int buflen)
{
int i;