- #1
ORF
- 170
- 18
Hello
I'm using the C functions for reading binary files:
But the rest of the program is in C++. I've tried with
but head doesn't change (I don't know if fread or [cout+hex] fails). Is something missing in the C++ code for reading binary files?
Thank you in advance ;)
Greetings
I'm using the C functions for reading binary files:
Code:
#include <iostream>
#include <stdio.h>
void main(){
/*********/
uint32_t head=0;
FILE *fin = NULL;
fin = fopen("myFile.bin","r");
while(myCondition){
fread(&head,4,1,fin);
std::cout << std::hex << head << std::endl;
}
fclose(fin);
/*********/
}
But the rest of the program is in C++. I've tried with
Code:
#include <fstream>
#include <ios>
void main(){
/*********/
char head[4];
std::ifstream fin("myFile",std::ios::binary);
fin.read((char*) &head,sizeof(head));
while(myCondition){
fread(&head,4,1,fin);
std::cout << std::hex << head << std::endl;
}
fin.close();
/*********/
}
but head doesn't change (I don't know if fread or [cout+hex] fails). Is something missing in the C++ code for reading binary files?
Thank you in advance ;)
Greetings
Last edited by a moderator: