Thread: Generic data structures - C

  1. #1
    Registered User
    Join Date
    Nov 2019
    Posts
    135

    Generic data structures - C

    Hey all!

    On Friday I'm taking my final exam on C before we continue to the second half of the course on C++.

    There will be like 6 questions in the exam, where one of them is writing an entire code.
    We are told that we should go through generic data structures, so I believe there will be some coding question implementing generic data structure.

    I didn't find a lot of good and complete examples of generic data structures in C, so maybe someone here can give me a good reference to generic data structure implementations.

    Thank you.

  2. #2
    Registered User
    Join Date
    Aug 2019
    Location
    inside a singularity
    Posts
    308
    C doesn't have the kind of support C++ has for generic data structures. templates in C++ are a very, very, very powerful tool for generic implementations.
    I googled and tried to find something good enough but I haven't gone through it completely. Just glanced through as I need to study for my Chemistry Pre-boards this week, these seemed good but idk for sure.

    Simulation of templates in C (for a queue data type) - Stack Overflow
    generic data structure in C - Stack Overflow
    blog
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    @Zeus, perhaps if you don't know anything about a topic you can just shut the f up? He can use google himself.

    At any rate, in C "generic data structure" can mean a couple of different things. It can be a struct that is created with a macro that adds in the types to the actual source code, or it can use void* to point to an object of arbitrary type. Which are you talking about?
    A little inaccuracy saves tons of explanation. - H.H. Munro

  4. #4
    Registered User
    Join Date
    Nov 2019
    Posts
    135
    Zeus - Thanks, I'll go through it - exploring the relevance of each.
    John - The second approach - they expect us to be able to use void pointers, creating by them some generic functions, data structures, etc...

    Thank you guys.

  5. #5
    Registered User
    Join Date
    Aug 2019
    Location
    inside a singularity
    Posts
    308
    > He can use google himself.

    Damn, why you so salty most of the time?

    He mentions "I didn't find a lot of good and complete examples of generic data structures in C, so maybe someone here can give me a good reference to generic data structure implementations.". Don't blame me, I know what generic refers to in C++ and there's only one way in which I've learnt it. You may be more experienced but that doesn't mean what I'm trying to do is wrong. Perhaps, you can shut the f up and learn to acknowledge that it takes a decent amount of time for different people to learn most, if not all, about the language.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generic Pointers to structures
    By dunxton in forum C Programming
    Replies: 8
    Last Post: 02-20-2009, 10:23 AM
  2. State manager generic data
    By cboard_member in forum Game Programming
    Replies: 3
    Last Post: 06-06-2006, 10:52 AM
  3. Replies: 2
    Last Post: 06-16-2005, 10:03 AM
  4. Generic data structures
    By rzcodeman in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2005, 08:58 AM
  5. templates, generic data types
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 05-01-2002, 02:29 AM

Tags for this Thread