Click here to Skip to main content
15,902,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: destroy a dialog in a MFC application Pin
tom groezer9-May-08 3:26
tom groezer9-May-08 3:26 
GeneralRe: destroy a dialog in a MFC application Pin
Mark Salsbery9-May-08 6:15
Mark Salsbery9-May-08 6:15 
Questionfputc or fgetc returning odd results Pin
Klempie9-May-08 2:03
Klempie9-May-08 2:03 
AnswerRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 2:28
Klempie9-May-08 2:28 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 2:37
Rajkumar R9-May-08 2:37 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 2:40
Klempie9-May-08 2:40 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 2:50
Klempie9-May-08 2:50 
AnswerRe: fputc or fgetc returning odd results [modified] Pin
Rajkumar R9-May-08 3:38
Rajkumar R9-May-08 3:38 
Klempie wrote:
unsigned int dict_size = readintbigendian(in);


in your code for writting you didn't shown writting dictionary size.
Klempie wrote:
if(!writeintbigendian ( out, dictionary[i+1] ))

write start from 1;

may be you are writting it, I still don't believe problem in file read if you properly used it, if you not writting the dictionary size and read it, the fgetc(file); return EOF at end of file at that time, EOF value is -1 you get it instead of -230; you are not checking error status of fgetc, check it.

the following code for me works well,

#include <stdio.h>

FILE *fpWrite = NULL, *fpRead = NULL;

int iArrDataWrite[] = {	1,2,3,4,5,6,7,8,9,10,
					11,12,13,14,15,16,17,18,19,20,
					21,22,23,24,25,26,27,28,29,30,
					31,32,33,34,35,36,37,38,39,40,
					41,42<big>,-230</big>,44,45,46,47,48,49,50,
					51,52,53,54,55,56,57,58,59,60
				};


#define DATA_SIZE (sizeof(iArrDataWrite)/sizeof (iArrDataWrite[0]))

int iArrDataRead[DATA_SIZE] = {0};

int main( void )
{
   int numclosed;

   if((fpWrite  = fopen( "bigEndianData.bin", "wb" )) == NULL ) 
   {
      printf( "The file 'bigEndianData.bin' was not opened for writting\n" );
	  return 0;
   }
   else
   {
	   printf( "The file 'bigEndianData.bin' was opened for writting\n" );
	   printf( "Writting to file\n" );
	   for (int i = 0; i < DATA_SIZE; i++)
	   {
		   printf( "%d,", iArrDataWrite[i]);
		   if (((i + 1) % 10) == 0) printf( "\n");
		   writeintbigendian(fpWrite, iArrDataWrite[i]);
	   }
	   fclose( fpWrite);
	   fpWrite = NULL;
   }

   if((fpRead  = fopen( "bigEndianData.bin", "rb" )) == NULL ) 
   {
      printf( "The file 'bigEndianData.bin' was not opened for reading\n" );
	  return 0;
   }
   else
   {
	   printf( "The file 'bigEndianData.bin' was opened for reading\n" );
	   printf( "reading from file\n" );
	   for (int i = 0; i < DATA_SIZE; i++)
	   {
		   iArrDataRead[i] = readintbigendian(fpRead);
		   printf( "%d,", iArrDataRead[i]);
		   if (((i + 1) % 10) == 0) printf( "\n");		   
	   }
	   fclose( fpRead);
	   fpRead = NULL;
   }
   return 0;
}


modified on Friday, May 9, 2008 10:13 AM

GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 4:15
Klempie9-May-08 4:15 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 4:21
Rajkumar R9-May-08 4:21 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 4:28
Klempie9-May-08 4:28 
AnswerRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 4:48
Klempie9-May-08 4:48 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 5:05
Rajkumar R9-May-08 5:05 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 4:56
Rajkumar R9-May-08 4:56 
AnswerRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 5:06
Klempie9-May-08 5:06 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 5:10
Rajkumar R9-May-08 5:10 
AnswerRe: fputc or fgetc returning odd results Pin
toxcct9-May-08 3:06
toxcct9-May-08 3:06 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 3:38
Klempie9-May-08 3:38 
GeneralRe: fputc or fgetc returning odd results Pin
toxcct9-May-08 3:45
toxcct9-May-08 3:45 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 3:47
Klempie9-May-08 3:47 
GeneralRe: fputc or fgetc returning odd results Pin
toxcct9-May-08 3:50
toxcct9-May-08 3:50 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 3:53
Klempie9-May-08 3:53 
GeneralRe: fputc or fgetc returning odd results Pin
Rajkumar R9-May-08 4:27
Rajkumar R9-May-08 4:27 
GeneralRe: fputc or fgetc returning odd results Pin
CPallini9-May-08 5:01
mveCPallini9-May-08 5:01 
GeneralRe: fputc or fgetc returning odd results Pin
Klempie9-May-08 5:06
Klempie9-May-08 5:06 

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.