Safer Alternatives to the C Standard Library

后端 未结 6 1504
广开言路
广开言路 2021-02-07 10:29

The C standard library is notoriously poor when it comes to I/O safety. Many functions have buffer overflows (gets, scanf), or can clobber memory if n

6条回答
  •  一生所求
    2021-02-07 11:23

    I use GLib library, it has many good standard and non standard functions.

    See https://developer.gnome.org/glib/stable/

    and maybe you fall in love... :)

    For example:

    https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup-printf

    explains that g_strdup_printf is:

    Similar to the standard C sprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result.

提交回复
热议问题