Thread: strcpy and 2d malloc

  1. #16
    Registered User
    Join Date
    Dec 2012
    Posts
    54
    Quote Originally Posted by std10093 View Post
    newline character I guess is that you have in there.
    Yes, i did what you said..

  2. #17
    Registered User
    Join Date
    Dec 2012
    Posts
    54
    Well???

  3. #18
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2010, 07:42 AM
  2. Replies: 7
    Last Post: 05-19-2010, 02:12 AM
  3. strcpy
    By Abda92 in forum C Programming
    Replies: 7
    Last Post: 09-13-2006, 10:05 AM
  4. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 04:11 PM
  5. HELP!! strcpy
    By abbynormal87 in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2002, 07:34 AM