James2007

Hi

agian!

I have this code now, I was using ifstream, but it was well over my head, didn't understand it. But what I'd like to do with this code is get the buf to read in 64 bits (8bytes), which is does. But I would like to output the decmial value of that interger. However it seem just to but the 8 bytes back into the txt file.

How do I get it to print of the number from the buffer

the interger being displayed by value Oneline, is not correct. I can't figure out what it is doing

Eventually I'll get this program to read in a whole file, I was thinking of 8byte at a time, and print it off to a file. Using a while(!eof) statement, please would you let me know if that's not possible

 

#include <stdio.h>

#include <stdlib.h>

 

 

int main(void)

{

 

      unsigned __int64 Oneline;

   

      char buf[ 8];

      int index;

      FILE *fptr;

 

      if (( fptr = fopen ( "test.jpg", "rb" ) ) == NULL ){

            printf ( "Cannot open file\n" );

            exit ( 1 );

      }

     

      fread ( buf, 1, sizeof(buf), fptr );

 

      fclose ( fptr );

 

 

 

 

      if (( fptr = fopen ( "Kounter-report31.txt", "w+" ) ) == NULL )     {

            printf ( "Cannot open file\n" );        

            exit ( 1 );    

      }   

 

      fprintf(fptr,"%I64u\n",Oneline);

      fwrite ( buf, 1, sizeof(buf), fptr );    

      fclose ( fptr );    

 

      }

 

Thanking you kindly for you time

James




Re: Visual C++ General reinterpret_cast

einaros

Try

unsigned __int64 x;
fread(reinterpret_cast<char*>(&x), 1, sizeof(x), fptr);






Re: Visual C++ General reinterpret_cast

James2007

Sorry about the delay in reply

Thanks very much

James