Click here to Skip to main content
15,923,197 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Application that handles 200 000+ Lines? Pin
Steve The Plant24-Jun-03 17:17
Steve The Plant24-Jun-03 17:17 
GeneralRe: Application that handles 200 000+ Lines? Pin
basementman25-Jun-03 5:11
basementman25-Jun-03 5:11 
QuestionDrawing without flicker? Pin
Aidman24-Jun-03 15:25
Aidman24-Jun-03 15:25 
AnswerRe: Drawing without flicker? Pin
John M. Drescher24-Jun-03 15:45
John M. Drescher24-Jun-03 15:45 
AnswerRe: Drawing without flicker? Pin
Dave Bryant24-Jun-03 15:46
Dave Bryant24-Jun-03 15:46 
GeneralRe: Drawing without flicker? Pin
Aidman24-Jun-03 15:51
Aidman24-Jun-03 15:51 
GeneralRe: Drawing without flicker? Pin
John M. Drescher24-Jun-03 15:54
John M. Drescher24-Jun-03 15:54 
GeneralRe: Drawing without flicker? Pin
Aidman24-Jun-03 15:59
Aidman24-Jun-03 15:59 
GeneralRe: Drawing without flicker? Pin
J. Dunlap24-Jun-03 16:12
J. Dunlap24-Jun-03 16:12 
GeneralRe: Drawing without flicker? Pin
Ryan Binns24-Jun-03 16:13
Ryan Binns24-Jun-03 16:13 
GeneralRe: Drawing without flicker? Pin
John M. Drescher24-Jun-03 16:19
John M. Drescher24-Jun-03 16:19 
GeneralRe: Drawing without flicker? Pin
Ryan Binns24-Jun-03 16:21
Ryan Binns24-Jun-03 16:21 
Generalplay avi file and install codec for it Pin
Mohsen Saad24-Jun-03 15:17
Mohsen Saad24-Jun-03 15:17 
GeneralHelp!! CHTMLView inside CDialog Pin
crewchill24-Jun-03 14:09
crewchill24-Jun-03 14:09 
GeneralRe: Help!! CHTMLView inside CDialog Pin
Joan M24-Jun-03 20:34
professionalJoan M24-Jun-03 20:34 
GeneralRe: Help!! CHTMLView inside CDialog Pin
crewchill24-Jun-03 21:21
crewchill24-Jun-03 21:21 
GeneralLots'o'data... Pin
el davo24-Jun-03 13:25
el davo24-Jun-03 13:25 
GeneralRe: Lots'o'data... Pin
Dave Bryant24-Jun-03 14:34
Dave Bryant24-Jun-03 14:34 
QuestionWhat's wrong with this code? Pin
Jonathan Gilligan24-Jun-03 12:38
Jonathan Gilligan24-Jun-03 12:38 
AnswerRe: What's wrong with this code? Pin
Dave Bryant24-Jun-03 12:43
Dave Bryant24-Jun-03 12:43 
AnswerRe: What's wrong with this code? Pin
ZoogieZork24-Jun-03 14:11
ZoogieZork24-Jun-03 14:11 
GeneralRe: What's wrong with this code? Pin
Jonathan Gilligan25-Jun-03 5:20
Jonathan Gilligan25-Jun-03 5:20 
Generalfopen Pin
cnd1200124-Jun-03 11:11
cnd1200124-Jun-03 11:11 
Hello everybody,

Here is my problem.

I wrote a program that does a statistical analysis, allocating large quantities of memories (3-400 MB) dynamically, and then performs cycles of calculations on the data.
At the end of each cycle, the program opens 2 files in sequence and writes the results to the disk.

With the first file there is no problem, with the second everything goes well for 20-30 cycles (on average, but the figure varies), when the fopen() that should open the file fails, returning a null pointer. If I try to make it open the same file (which is always the same file that it opened without problems for the first 20-30 cycles) passing to the fopen the name in “” instead of passing a variable, it still doesn’t open it.
If I give it a wayout letting it open another file somewhere else, it succeeds and goes on.
At the next cycle, it reopens the old file without problems.
It is as the write permission on that file were temporarily altered in a cycle, to be brought back to their original values in the next cycle.

The problem occurs with 3 different compilers (borland, Visual C++, mingw) and on 2 operating systems (windows NT e windows ME) , running on 2 different machines (both pentium)

I tried to launch the program from the Visual C++ debugger with all the cheks activated, putting also checks on the heap (functions _CrtMemCheckpoint, _ASSERTE( _CrtCheckMemory( ) )), but apparently there is no memory corruption problem.

Here is the function savememory where the error occurs.

//------------------------------------------------------------------------------
// FNCT: Sieve::savememo
//------------------------------------------------------------------------------
void Sieve::savememo(void)
{
int    lr,nd,i,j,b,var1,* fp2;
Node * ndp;

fp = fopen(MEMORYFILE,"w");

fprintf(fp,"\n%d",cyc);
for (lr=1; lr<LAYERS; lr++) {
   fprintf(fp,"\n\nLR %d",lr);
   for (nd=0; nd<nn[lr]->dimlr; nd++) {
      ndp = nn[lr]->nodes[nd];
      fprintf(fp,"\n%3d) ; %.3f ;",nd,ndp->score);
      for (i=0; i<MAXIPNDS; i++) {
         fprintf(fp," [%3d",  ndp->memo.inar[i].ndnr);
         fprintf(fp," %5.2f", ndp->memo.inar[i].wht);
         fprintf(fp," (%3d",  ndp->memo.inar[i].spc.x1);
         fprintf(fp," %3d)",  ndp->memo.inar[i].spc.x2);
         var1 = (int)ndp->memo.inar[i].spon;
         fprintf(fp," %d] ;", var1);
      }
      fprintf(fp," [%5.2f  -1] ;", ndp->memo.bias);
      fprintf(fp," (%2d %2d)",     ndp->memo.a.x1,ndp->memo.a.x2);
      fprintf(fp," (%2d %2d)",     ndp->memo.b.x1,ndp->memo.b.x2);
   }
}

if (fclose(fp)) 
   printf("Error closing file\n");

#ifdef DEBUG2
printf("AFTER WRITE MEMORYFILE I AM! \n");
printf("\n%s %d\n", DNAMEMFILE, cyc);
#endif
fp = fopen(DNAMEMFILE,"w");
#ifdef DEBUG2
printf("\nfp: %p\n", fp);
//fprintf(fp,"\n%d",cyc);
if (fp == NULL) 
   fp = fopen("C:\\ZEUG\\ZOS\\MPXVC\\IOX\\MPXDNA0.TXT","w");  
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\MPXVC\\IOX\\MPXDNA2.TXT","w");  
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\MPX\\IOX\\MPXDNA3.TXT","w");  
if (fp == NULL) fp = fopen("C:\\ZEUG\\ZOS\\FILE01.txt","wt");  

printf("AFTER fopen(DNAMEMFILE) I AM! \n");
#endif

for (lr=1; lr<LAYERS; lr++)
   for (nd=0; nd<nn[lr]->dimlr; nd++) {
      fprintf(fp,"\n\nlr %d nd %d dimpop %d\n",lr,nd,
         nn[lr]->nodes[nd]->popp->dimpop);
      for (j=0; j<DIMPOP; j++) {
         fprintf(fp,"\n%5.3f %5.3f",nn[lr]->nodes[nd]->popp->guys[j].score,
            nn[lr]->nodes[nd]->popp->guys[j].dd);
         for (b=0; b<DIMDNA; b++) {
            var1 = (int)nn[lr]->nodes[nd]->popp->guys[j].dna[b];
            fprintf(fp," %d",var1);
         }
      }
   }

fclose(fp);
#ifdef DEBUG2
printf("AFTER WRITE DNAMEMFILE I AM! \n");
#endif

}



Help, I’m getting crazy!

Thank you

Alex
GeneralRe: fopen Pin
Neville Franks24-Jun-03 11:44
Neville Franks24-Jun-03 11:44 
GeneralRe: fopen Pin
cnd1200125-Jun-03 22:08
cnd1200125-Jun-03 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.