In post number 4, in line 77, the bracket that closes is of the for loop with the j counter. Thus, when you reach the printf's of w, counter j has the value size (because the condition is j<size in the for loop). As a result, you are reading memory that does not have what you think it does. By chance, this memory is yours and the program does not crush.
So, you should rethink about counter j.
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson