Ya, none of that worked :(.
Here's the error exception:
Current Snippet:Code:Unhandled exception at 0x5c636af2 in cs36FINAL.exe: 0xC0000005: Access violation writing location 0x00000024.
Debugger doesn't show any errors. THe error shows up on runtime and shows to this line:Code://Save the array of structures to a text file.void savetext(struct Stock s[], int n)
{
FILE *f;
f = fopen("e:\\final.txt", "w");
int i;
for(i=0;i<n;i++)
{
fprintf(f,"%s\n",s[i].name);
fprintf(f,"%d %f %f %f %f %f %f", s[i].numShares, s[i].buyShare, s[i].currPrice, s[i].fees, s[i].initCost, s[i].currCost, s[i].profit);
}
fclose(f);
fflush(stdin);
}
//Retrieve and print the text file.
void loadtext(struct Stock s[], int n)
{
FILE *f;
f = fopen("e:\\final.txt", "r");
int i;
for(i=0;i<n;i++)
{
fgets(s[i].name, sizeof(s[i].name), f);
fscanf(f,"%d %f %f %f %f %f %f", s[i].numShares, s[i].buyShare, s[i].currPrice, s[i].fees, s[i].initCost, s[i].currCost, s[i].profit);
}
fclose(f);
}
//Save the array of structures to a binary file.
void savebin(struct Stock s[], int n)
{
FILE *f;
f = fopen("e:\\final.bin", "wb");
if (! f)
{ printf("Could not write to file");
exit(1); }
fread(s, sizeof(struct Stock), n, f);
fclose(f);
}
//Retrieve and print the binary file.
void loadbin(struct Stock s[], int n)
{
FILE *f;
f = fopen("e:\\final.bin", "rb");
if (! f)
{ printf("Could not open the file");
exit(1); }
fread(s, sizeof(struct Stock), n, f);
fclose(f);
}
Uggghhhh Sorry guys. I'm new and stupid with farrrrrrr less experience than probably most of you. Could you skim through the code to see if there's something complicating this issue? I even checked the perms for the files. You see it will write them to disk, but won't read them, or bugs out when it attempts (By it i mean the IDE/Debugger). I honestly don't know whats causing it....Code:fscanf(f,"%d %f %f %f %f %f %f", s[i].numShares, s[i].buyShare, s[i].currPrice, s[i].fees, s[i].initCost, s[i].currCost, s[i].profit);