Still having problems with printing out INT64 integers
I am still having problems with this code. This prints out a number, but it's not exactly what I want. I need to print out an INT64 number that is in sync all the way through. For example:
The hex: FF D8 FF E1 1E 63 45 78 is the first line of the file test.jpg. I would like to display its integer (unsigned) value: 18435766416983672184
But what it does it prints out is the number for hex 78 45 63 1E E1 FF D8 FF, which is 8666442042236197119.
I thought this would be ok, but later when I want to do more stuff to the program it won't work.
There has to be a simple way of reading in 64 bits of data and then output the decimal value into a .txt file. Please can someone help me!
This is the code I have now, but if you can suggest a better way, IĄŻll take it!
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned __int64 Oneline;
char buf[ 8];
FILE *INfptr;
FILE *OUTfptr;
if ((fptr = fopen( "test.jpg", "rb" )) == NULL ){
printf ( "Cannot open file\n" );
exit ( 1 );
}
if ((fptr = fopen( "Kounter-report32.txt","w+"))== NULL ){
printf ( "Cannot open file\n" );
exit ( 1 );
}
do{
fread ( buf, 1, sizeof(buf), INfptr );
// fread(reinterpret_cast<char*>(&Oneline), 1, sizeof(Oneline), INfptr);
(WAS using serveral different methods of reading and writing, they worked but not the way I need it too.)
fprintf(OUTfptr,Ą±%I64u/tĄ±, Oneline);
}while (!feof (INfptr));
fclose ( INfptr );
fclose ( OUTfptr );
}
Thank you once again, and sorry for troubling you guys so much
James