writing formatted data of unknown length to a string (C programming)

后端 未结 5 1028
Happy的楠姐
Happy的楠姐 2020-12-31 11:36

The following C function:

int sprintf ( char * str, const char * format, ... );

writes formatted data to a string. The size of the array pa

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 12:08

    You can use either snprintf or asprintf. snprintf involves checking the size and resizing if necessary, whereas asprintf simply allocates the correct size for you.

提交回复
热议问题