This is a discussion on strcpy and 2d malloc within the C Programming forums, part of the General Programming Boards category; Originally Posted by std10093 newline character I guess is that you have in there. Yes, i did what you said.....
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