Thread: Void *

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    197

    Void *

    I have a scenario in which user types int,float or double.
    i use void pointers and pass it to a function.

    Code:
    void get (void * elm)
    {
    
    
    
    ---------------
    
    }
    Is there any way to get the size of the element in the get function (for char :1 etc...)
    ofcourse if we pass another parameter to the get function while calling this can be done.
    But my question is whether can i get the size without pass the size to the function.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    The 2 most straightforward things to do would be the following:

    1) do as you yourself suggested and pass an additional argument
    2) pass a struct containing type and void * (struct Value { enum type, void *val })

    Note to the moderators: board won't let me post because of my inline (not-necessarily-syntactically-correct code sample) above, instead demanding code tags. This is *not* an improvement. And as you can see, easy enough to circumvent. MUHAHAHA.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    MWAAAHAAA, it's to stop newbies from posting code without code tags.
    How THEY do to circumvent it, I don't know. But I know it's possible.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matrix operations using objects
    By circuitbreaker in forum C++ Programming
    Replies: 7
    Last Post: 05-04-2010, 08:53 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  4. msvc just ate one of my source files
    By Eber Kain in forum C++ Programming
    Replies: 6
    Last Post: 07-01-2004, 05:40 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM