要批量生成文件名,如:c:\\001.xxx 到c:\\002.xxx
我要循环生成一批文件,名如:
c:\\001.xxx 到c:\\002.xxx
怎么写?
谢谢各位老大...
[解决办法]
#define N 100
for(int i=1; i <N; i++)
{
CFile myFile;
CFileException ex;
CString strFileName;
strFileName.Format(_T( "%.3d.xxx "),i);
if(!myFile.Open(strFileName,CFile::modeCreate |
CFile::modeWrite | CFile::shareExclusive,&ex))
{
CString str;
TCHAR szError[255];
ex.GetErrorMessage(szError, 255);
str.Format(_T( "Could not create File: %s "), szError);
AfxMessageBox(str);
}
}
[解决办法]
c:\\001.xxx 到c:\\002.xxx
for( int x = 1; x < 1000 ; x++){
char sz[32]={0};
_snprintf( sz , 31, "C:\\%03d.xxx " , x );
FILE* fp=fopen( sz , "rw " );
fclose(fp);
}