vc++怎么实现顺序建立多个文件?

来源:百度知道 编辑:UC知道 时间:2024/06/01 04:51:53
想要按顺序生成一批文件,如1.txt,2.txt,3.txt......这个用vc++要怎么实现阿?谢谢!
首先谢谢一楼的大哥,在编译的时候总是提示说
Compiling...
下漫画1.cpp
c:\program files\microsoft visual studio\vc98\include\shlwapi.h(56) : error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\program files\microsoft visual studio\vc98\include\shlwapi.h(56) : error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\shlwapi.h(56) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
这个问题我不会调,能帮我看下吗?

CFile newfile;
CString path="c:\\";
CString str;
int Index;
for(int i=1;i<10;i++)
{
Index = path.ReverseFind('\\');
path = path.Left(Index);

str.Format("%d.txt",i);
path +="\\"+str;

if(newfile.Open(path,CFile::modeCreate|CFile::modeWrite))
{
str.Format("创建 %s 成功!",path);
AfxMessageBox(str);
}
newfile.Close();
}

这个试试吧,希望能帮上忙。

把头文件去了吧,这个好像用用不着。应为这些代码是从以前些的代码里找出来的,没多看。这个shlwapi.h头文件,在创建目录时才用得着。

#include "shlwapi.h"
#pragma comment(lib,"shlwapi.lib")

CFile newfile;
CString path="c:\\";
CString str;
int Index;
for(int i=1;i<10;i++)
{
Index = path.ReverseFind('\\');
path = path.Left(Index);

str.Format("%d.txt",i);
path +="\&