tags:

views:

49

answers:

2
+1  A: 

You're getting a segmentation fault because you are trying to write 3 characters into a 2 character array. (NUL is a character too)

Hasturkun
+1  A: 

sprintf is putting in a null character to terminate the string. So you need a three-character array to hold a two-character string; it's really 'a' 'b' '\0'.

Borealid