64,676
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
FILE *pfile;
DWORD hh=0;
while (true)
{
if ((pfile=fopen("c:\\1.txt","a"))==NULL)
if ((pfile=fopen("c:\\1.txt","w"))==NULL)
return 0;
fprintf(pfile,"%u\n",hh);
fclose(pfile);
//TRACE("hh=%u\n",hh);
cout<<hh<<endl;
hh++;
}
return 0;
}
#include <windows.h>
#include <stdio.h>
int main()
{
HANDLE hFile = CreateFile("C:\\1.txt", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING, 0);
unsigned int hh=0;
DWORD dwBytes;
unsigned char *block = new unsigned char[65536];
if( hFile == NULL)
return 0;
SetFilePointer(hFile, 65536, 0, FILE_BEGIN);
SetEndOfFile(hFile);
while (true)
{
memset(block, hh % 100, 65536);
SetFilePointer(hFile, 0, 0, FILE_BEGIN);
WriteFile(hFile, block, 65536, &dwBytes, NULL);
printf("%u\n", hh++);
}
CloseHandle(hFile);
return 0;
}