structures

This is a discussion on structures within the C Programming forums, part of the General Programming Boards category; i have those two structures Code: struct classbody { int count; struct streenode *namesroot; }; struct methodblockbody { int count ...

  1. #1
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90

    structures

    i have those two structures

    Code:
    struct classbody {
    	int count;
    	struct streenode *namesroot;
    };
    
    struct methodblockbody {
    	int count
    	struct streenode *namesroot;
    as you can see they "are" the same. they just differ in name because of code readability. is it safe to assign those to a function like
    Code:
    fname(void *blabla)
    {
         do something with blabla-> count or blabla->streenode
    }
    stormbringer

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    I'm not sure I understand your question....can you rephrase please.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90
    i have a function that takes a pointer to void as an argument.

    i also have the two structures above.

    i pass the structures one after another to the function. the function changes the structure fields. but the structures don't have the same name. is this sort of coding save?

    if i had a third structure like

    Code:
    struct classbody {
    	int count;
    	struct streenode *namesroot;
                    char something;
    };
    and would pass it to the function, would there be an access violation or will it be ok, as long as i just use the labels defined in all three structures.
    passing all three structures and just working on count and *namesroot works. but is it save, or will the programm sometimes crash?

    i hope i made myself clearer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM
  3. Input output with structures
    By barim in forum C Programming
    Replies: 10
    Last Post: 04-27-2004, 08:00 PM
  4. pointers to arrays of structures
    By terryrmcgowan in forum C Programming
    Replies: 1
    Last Post: 06-25-2003, 09:04 AM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21