Safer string functions (strlcpy, snprintf)
Në shqip: Funksionet më të sigurta për tekst
ShpjegimiSQ
strcpy() dhe strcat() s'e kontrollojnë madhësinë dhe shkaktojnë buffer overflow. snprintf() dhe strlcpy() (ku ekziston) s'shkruajnë kurrë jashtë vargut dhe gjithmonë e mbyllin me '\0'.
EnglishEN
strcpy() and strcat() don't check the size and cause buffer overflows. snprintf() and strlcpy() (where available) never write outside the array and always end with '\0'.
Si ta mendosh
Si një hinkë që ndalet vetë kur shishja mbushet.
Lexoje në anglisht
Like a funnel that stops by itself when the bottle's full.
Shembull kodic
char dest[8];
snprintf(dest, sizeof dest, "%s", "Prishtina"); // "Prishti" + '\0'