Well I\'ve weird problem with printf()
. It\'s outputting garbage on screen. It\'s kind of connected with memory I guess. Have a look:
char strin
finish your string2
with null character '\0'
string2[19] = '\0';
Or you can do it in this way:
for (i; i < 19; i++) string2[i] = ' ';
string2[i] = '\0'; // after the end of the loop i= 19 here
Because C strings need to be NUL terminated. This means the last char of your string must be '\0'
. This is how printf
(and all other C string functions) know when a string is finished.