C++ non null terminated char array outputting

后端 未结 5 590
刺人心
刺人心 2021-01-18 03:27

I was trying to output a not null terminated char array to a file.

Actual thing is, I am receiving packets and then printing their fields.

Now as these field

5条回答
  •  轮回少年
    2021-01-18 03:50

    A cheap solution would be to have a buffer that has space for an extra null character and just put a null character at the point when you know the actual size and then output the null-terminated buffer as you already do. Fast and reliable.

提交回复
热议问题