hi..
i'm learning C++ and i have a problem that has never happened to me before:
i have a project where i use text files.. i open the file, close it, start a FOR, open the file again (inside the FOR), and when i close the file again (inside the FOR) an error apears saying "..The memory could not be "read"".
the weirdest thing is that when i run the program in Debug, this doesn't happen and the program does what i want!!!
int count;
FILE *fin;
char wordtxtfile[50];
char txtfile[2][10];
/*****************************/
strcpy(txtfile[0],"PT.txt");
strcpy(txtfile[1],"FR.txt");
/*****************************/
count=11;
for (int x=0;x<2;x++)
{
if ((fin=fopen(txtfile[x],"r"))==NULL)
printf ("\nError");
else
{
for (int y=0;y<=count;y++)
{
fin=fopen(txtfile[x],"r");fclose(fin);
while (((fscanf(fin,"%s",wordtxtfile))!=EOF)
{
printf ("%s\n",wordtxtfile);
}
fclose(fin);
}
}
}
Please help me! i need this problem solved quickly.. =S
i'm learning C++ and i have a problem that has never happened to me before:
i have a project where i use text files.. i open the file, close it, start a FOR, open the file again (inside the FOR), and when i close the file again (inside the FOR) an error apears saying "..The memory could not be "read"".
the weirdest thing is that when i run the program in Debug, this doesn't happen and the program does what i want!!!
int count;
FILE *fin;
char wordtxtfile[50];
char txtfile[2][10];
/*****************************/
strcpy(txtfile[0],"PT.txt");
strcpy(txtfile[1],"FR.txt");
/*****************************/
count=11;
for (int x=0;x<2;x++)
{
if ((fin=fopen(txtfile[x],"r"))==NULL)
printf ("\nError");
else
{
for (int y=0;y<=count;y++)
{
fin=fopen(txtfile[x],"r");fclose(fin);
while (((fscanf(fin,"%s",wordtxtfile))!=EOF)
{
printf ("%s\n",wordtxtfile);
}
fclose(fin);
}
}
}
Please help me! i need this problem solved quickly.. =S