Guest gilgamesh Posted May 12, 2003 Posted May 12, 2003 i need to know how to add information to a ( .dat ) file from the run of my program, but i have to create a dummy file to prevent the information on my file from being deleted when i add new information to it. could any of you tell me how to make a dummy file, and add information so nothing is lost so i can add information during the run?
Guest SyntaXVB5 Posted May 31, 2003 Posted May 31, 2003 Can't you just write-protect the file :-\ Code-wise I could help you if you were more specific.
Guest Syntax Posted June 24, 2003 Posted June 24, 2003 I'm sorry I've been this late, and you probably dont even come to this thread any more but here goes code to create a simple dummyfile. I had to sacrifice file size, for speed in this program. (the mass usage of the character X). Shouldn' tbe too big though. /* Science Forums -- Keep it open source, pigs */ #include <stdio.h> #include <stdlib.h> void cls(); int main(void) { unsigned long c; char d[18] = "dummyfile"; printf("DummyFile 0.7A, Matt Dunleavy\n"); printf("File Size (KB): "); scanf("%d", &c); printf("Please Wait...\n"); /* Beginning of File I/O */ FILE * dummyfile; dummyfile = fopen(d, "w"); /* End of File I/O */ for (signed short int i = 1; i<c+1; i++) { fprintf(dummyfile, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } cls(); fclose(dummyfile); printf("Dummy File Created!\n"); return 0; } void cls() { system("cls"); /* uses the system command to clear the screen */ }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now