Problem writing int to binary file in C

前端 未结 6 2058
一整个雨季
一整个雨季 2021-01-06 21:11

I need to write data to a binary file using C\'s I/O functions. The following code causes a runtime exception :


#include \"stdio.h\"

int main(int argc,char         


        
6条回答
  •  执笔经年
    2021-01-06 22:16

    Adding to Neil's answer: this works when you are reading and writing the file on the same platform. Things can become weird if you are reading/writing across platforms with different endianness.

提交回复
热议问题