Implementing opaque abstract data types?

This is a discussion on Implementing opaque abstract data types? within the C Programming forums, part of the General Programming Boards category; Hello, How do I express the following instructions into "C" code? Pls give example. The instructions: Use structure pointers additionally ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Implementing opaque abstract data types?

    Hello,
    How do I express the following instructions
    into "C" code? Pls give example.

    The instructions:
    Use structure pointers
    additionally hidden behind typedefs;which point
    to structure types, that are not publicly defined.

    Thank you,

    Adock.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    DO YOUR OWN HOMEWORK
    This site is for helping people with (specific) problems, not doing the homework for them. Try on your own first and if you get stuck, we might help you if you give the right question.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    The Homeworker
    Guest
    Code:
    struct datastruct
    {
        int data;
    };
    
    typedef struct datastruct datastruct_s;
    typedef struct datastruct *pdatastruct_s;
    
    /* A pointer to the struct */
    pdatastruct datastruct_ptr;
    
    /* Allocate memory */
    datastruct_ptr = malloc (sizeof (datastruct_s));
    
    /* For safety check if operation was succesfull */
    if (datastruct_ptr == NULL)
        return ERROR;
    
    /* Using the member of the struct */
    datastruct_ptr->data = 2;
    
    /* Free memory when done */
    free (datastruct_ptr);

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Implementing opaque abstract data types

    This is very good. Thank you "The Homeworker".

    You're a scholar, and a gentleperson.

    Adock.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  2. What are abstract data types
    By bhagwat_maimt in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2007, 10:43 AM
  3. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 10:29 AM
  4. Dynamic data members?
    By confusalot in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2005, 11:15 AM
  5. using various data types in c language
    By sanju in forum C Programming
    Replies: 1
    Last Post: 11-28-2002, 10:24 AM

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