Thread: Error passing a string into a structure

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    Error passing a string into a structure

    SOLVED thanks to matsp, deleted because it's assignment work and don't want someone to copy important bits
    Last edited by JFonseka; 10-23-2007 at 06:06 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
          strcpy(command, node->name);
    Source
    Destination

    Are you sure you are copying the right way around?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Hehe thanks, it works now !

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    42
    Did you look at strcpy prototype?
    Code:
    char * strcpy ( char * destination, const char * source );

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by JFonseka View Post
    SOLVED thanks to matsp, deleted because it's assignment work and don't want someone to copy important bits
    Why not leave at least the bit of code that was faulty, in case someone else is wanting to know what it was I answered on? It badly disrupts the thread when the whole thread is removed later on.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,664
    Yes, deleting your post as soon as you think you've got an answer prevents anyone else from contributing, or from learning.

    > because it's assignment work and don't want someone to copy important bits
    If this bothers you, don't post your assignment code but instead create a small example which demonstrates the problem you're facing.
    - trying to do this can tell you the problem anyway, even without having to post anything.
    - simple examples are much quicker for us to work through.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Oh ok sorry, I'll keep that in mind.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  4. problems with overloaded '+' again
    By Brain Cell in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2005, 05:13 PM
  5. Replies: 12
    Last Post: 10-14-2003, 10:17 AM