Thread: cannot assign struct member values

  1. #1
    Registered User
    Join Date
    Feb 2015
    Posts
    1

    Angry cannot assign struct member values

    I'm a C beginner trying to assign struct member values to other struct members to
    create a list
    I've tried dot notation, pointer notation, strcpy, memcpy, memmove and normal assignment.
    Nothing has worked
    If anyone can help it would be much appreciated

    cust_list.h
    Attached Files Attached Files

  2. #2
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    Quote Originally Posted by snow365 View Post
    I'm a C beginner trying to assign struct member values to other struct members to
    create a list
    I've tried dot notation, pointer notation, strcpy, memcpy, memmove and normal assignment.
    Nothing has worked
    If anyone can help it would be much appreciated

    cust_list.h
    First, what exactly are you trying to do ? Maybe you could tell us what you are trying to do then we could start from there.

    Second, please post the code you wrote - the code you posted seems like -just- what you were given by a lecturer or something.

  3. #3
    Registered User
    Join Date
    Feb 2015
    Posts
    1
    Quote Originally Posted by Aslaville View Post
    First, what exactly are you trying to do ? Maybe you could tell us what you are trying to do then we could start from there.

    Second, please post the code you wrote - the code you posted seems like -just- what you were given by a lecturer or something.
    Firstly, I'm trying to create a list - more specifically a linked list
    Another module has populated the struct - this now is my data input for the list

    Secondly, this is lecture code adapted (which I'm allowed, but don't want)
    The reason for doing this is that my attempt failed - the obvious reason was loosing track of what I was doing, which can only be from lack of understanding
    By doing this I now understand

    So, I'm not worried about the code to create a linked list - the problem is in my two tries and this one, nothing I do allows me to assign cptr.custHead->member value or cp->custHead->member value (input) to new.member or new->member

    Until I sort this, I can't continue

    So as I said - any help is greatly appreciated

    ps I added the other modulets_utility.cts_utility.h

  4. #4
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by snow365 View Post
    Firstly, I'm trying to create a list - more specifically a linked list
    Another module has populated the struct - this now is my data input for the list

    Secondly, this is lecture code adapted (which I'm allowed, but don't want)
    The reason for doing this is that my attempt failed - the obvious reason was loosing track of what I was doing, which can only be from lack of understanding
    By doing this I now understand

    So, I'm not worried about the code to create a linked list - the problem is in my two tries and this one, nothing I do allows me to assign cptr.custHead->member value or cp->custHead->member value (input) to new.member or new->member

    Until I sort this, I can't continue

    So as I said - any help is greatly appreciated
    What Aslaville means is that you have not given us sufficient information to let us help you.

    Read Short, Self Contained, Correct Example and maybe How To Ask Questions The Smart Way. Then post an example of what you are trying to do inside code tags.
    "A Professor of Computer Science gave a paper on how he uses Linux to teach his undergraduates about operating systems. Someone in the audience asked why use Linux rather than Plan 9?' and the professor answered:Plan 9 looks like it was written by experts; Linux looks like something my students could aspire to write'."

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by snow365 View Post
    I'm a C beginner trying to assign struct member values to other struct members to
    create a list
    I've tried dot notation, pointer notation, strcpy, memcpy, memmove and normal assignment.
    Nothing has worked
    If anyone can help it would be much appreciated

    cust_list.h
    Why do you
    Code:
    typedef struct customerNode
    {
       ...
    } CustomerNodeType;
    ?

    I see people doing this all the time. Why?
    When
    Code:
    struct CustomerNodeType
    {
       ...
    };
    would work fine.

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    That happens a lot in C code because the struct (and union) keyword would need to precede the type name otherwise, wherever it is used.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I assign values to elements of a 2D array?
    By Karyumi in forum C Programming
    Replies: 9
    Last Post: 06-21-2012, 02:48 PM
  2. Why does C assign values to arrays like this?
    By FromJavatoC in forum C Programming
    Replies: 12
    Last Post: 08-12-2011, 04:52 PM
  3. Struct assign values iterate string
    By kaylaneko in forum C Programming
    Replies: 2
    Last Post: 11-16-2010, 10:51 PM
  4. Assign struct member value to struct member value
    By thahemp in forum C Programming
    Replies: 5
    Last Post: 10-13-2010, 09:48 AM
  5. 3-d array assign string values
    By WaterNut in forum C++ Programming
    Replies: 8
    Last Post: 07-01-2004, 12:02 AM