Will this code work?

It is my first time testing out files, and I have already had one BSOD due to really bad coding, could you please tell me if this is going to work. I just have a bad feeling about it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>

typedef unsigned long int u_long;

void getPass(){
	u_long cPass;
	FILE * passFile;
	passFile = fopen("C:\\passfile.txt","w");
	if (passFile!=NULL){
		for (cPass=0000000001;cPass<=9999999999;cPass++){
			printf("Writing %.10lu to file passfile.txt\n",cPass);
			fprintf(passFile,"%.10lu\n",cPass);
			fflush(passFile);
		}
	}
	fclose(passFile);
	delete passFile;
}

int main()
{
    getPass();
    return 0;
}
Last edited on
closed account (zb0S216C)
Asif Hirai wrote:
Will this code work?

Does it compile?

Also, you never new'd anything, so why is delete there? That'll cause problems on its own.

Wazzak
It does compile without any warnings and i have -Wall, but so did the one that cause the BSOD. and I removed the delete, that was junk from the c++ file io that I had to create.
Last edited on
Topic archived. No new replies allowed.