- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
Hope
#define OPTIONS "a+"
int i;
FILE *fd;
strcpy_s(lictmpfile,12,"r5lic");
fd = fopen(lictmpfile,"w");
if (fd == NULL) {
printf("Error creating %s\\n", lictmpfile);
return -1;
}
fclose(fd);
for(i=0; i
fd = fopen(lictmpfile,OPTIONS);
if (fd == NULL) {
printf("Error opening %s\\n", lictmpfile);
return -1;
}
fprintf(fd,table.EncodedString);
fprintf(fd,"\\n");
}
fclose(fd);
return 0;
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to recreate your problem. Notice I put the fopen and fcloseoutside the for loop and it works as expected.
!% cat t.c
#include
#include
#define OPTIONS "a+"
int i;
FILE *fd;
const int NumLicenses = 4;
int main() {
char lictmpfile[12];
strcpy_s(lictmpfile,12,"r5lic");
fd = fopen(lictmpfile,"w");
if (fd == NULL) {
printf("Error creating %s\n", lictmpfile);
return -1;
}
fclose(fd);
fd = fopen(lictmpfile,OPTIONS);
if (fd == NULL) {
printf("Error opening %s\n", lictmpfile);
return -1;
}
for(i=0; i
fprintf(fd,"\n");
}
fflush(fd);
fclose(fd);
return 0;
}
!% icl t.c && ./t.exe
Intel C++ Compiler XE for applications running on IA-32, Version Mainline Bet
a Build x
Built Apr 2 2012 21:38:41 by jward4 on JWARD4-DESK in D:/workspaces/cfe/dev
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
t.c
Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.
-out:t.exe
t.obj
!% cat r5lic
foo
foo
foo
foo
Please provide a complete compilable example of what isn't working as you expect.
thanks
Judy

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page