Remove C99-only feature (declaring variable inside for loop initialiser)
Avoid buffer overflows (sprintf -> snprintf & strcpy -> strncpy)
Merge pull request #2 from nxg/master

remove c99-only feature and fix buffer-overflow problems