Thread: how to make function return value go to structure record

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    37

    how to make function return value go to structure record

    Hello,

    I have a question in regards to how do I make a function return value go to a specific record of a structure.

    I have tried a few ways to do this but can't seem to see how to do it. Maybe i just can't see the obvious when it is in front of me

    I now how to set records of a structure when in the main function but i have a specific return value of a function I want to set in the structure record.

    as an example:

    Code:
    typedef struct
    {
    	char name[21];
    	char city[21];
    	char state[3];
    } Rec;
    typedef Rec *RecPointer;
    
    RecPointer r;
    r = (RecPointer)malloc(sizeof(Rec));
    
    strcpy((*r).name, "Leigh");
    but what if I want the "Leigh" set to r->name from a seperate function?

    Like this:
    Code:
    r->name = function()
    I know it isn't the right way but am unsure on how to proceed with this.

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    37
    solved it!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM