[SDL] Strings, seg faults, and memory

Simon Roby simon.roby at gmail.com
Sun Jun 26 11:53:16 PDT 2005


On 6/26/05, Gabriel <mystml at adinet.com.uy> wrote:
> char str[1024];
> sprintf(str, "%i", 1234);

You really should use snprintf though.

#define STR_LEN 1024
...
char str[STR_LEN];
sprintf(str, STR_LEN, "%i", 1234);

Writing on strings without locking the bounds is evil.

- SR




More information about the SDL mailing list