reading fortran binary file in c++

后端 未结 2 373
再見小時候
再見小時候 2021-01-24 00:29

The problem of reading (with c++ program) binary file generated by fortran code has been asked many times and the satisfactory description of conventions in fortran records has

相关标签:
2条回答
  • 2021-01-24 01:19

    operator>> is the formatted input operator. It is used to read text files, converting the textual representation to binary.

    You should be reading using unformatted input operations. Try this:

    file.read(reinterpret_cast<char*>(&ival), sizeof ival);
    

    Of course, after you read it, you may need to byte swap for correct endian representation.

    0 讨论(0)
  • 2021-01-24 01:22

    Open it in a hex editor and dig out the structure. Is the header size 16, 32, 64 or 128 bits and which end up is it?

    Hex editor..

    0 讨论(0)
提交回复
热议问题