C read binary stdin

前端 未结 8 2201
难免孤独
难免孤独 2020-11-30 04:51

I\'m trying to build an instruction pipeline simulator and I\'m having a lot of trouble getting started. What I need to do is read binary from stdin, and then store it in me

8条回答
  •  温柔的废话
    2020-11-30 05:46

    Consider using SET_BINARY_MODE macro and setmode:

    #ifdef _WIN32
    # include 
    # include 
    # define SET_BINARY_MODE(handle) setmode(handle, O_BINARY)
    #else
    # define SET_BINARY_MODE(handle) ((void)0)
    #endif
    

    More details about SET_BINARY_MODE macro here: "Handling binary files via standard I/O"

    More details about setmode here: "_setmode"

提交回复
热议问题