下面程序为什么不能循环呢,只在D盘里生成一个0.txt文件,并写入内容就退出了。大家帮忙看下,哪里出错了,谢谢~#include "stdafx.h"
#include <windows.h>
#include <string.h>
int main(int argc, char* argv[])
{
char Path[255]="D:";
char FileName[255];
char Data[512]="---------------------just for fun---------------------";
for(int i=0;i<100;i++)
{
wsprintf(FileName,"\\%d.txt",i);
strcat(Path,FileName);
HANDLE hFile;
hFile=CreateFile(Path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (hFile==INVALID_HANDLE_VALUE)
{
continue;
}
DWORD dwWrite;
WriteFile(hFile,&Data,strlen(Data),&dwWrite,NULL);
CloseHandle(hFile);
memset(Path,0x00,255);
memset(FileName,0x00,255);
}
return 0;
}