Thread: typedef

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    18

    typedef

    can any body tell me the answer to this question plz

    create snippet of C code that consists of two declarations defining a type called "zan", which should be a struct containing two members: first an unsigned int called "aku", then a constant pointer to char called "soku".

    To make things more interesting, you can't use any whitespace in either declaration, and the two declarations must be sufficiently dissimilar (basically, you have to use two different tricks to get around the lack of whitespace).


    i have figured out one solution
    Code:
    typedef/**/struct/**/{unsigned/**/*aku;char/**/*soku;}zan;
    here i use /* */ comments to delimit the keywords.
    but i cant get the other solution
    Last edited by Salem; 04-02-2007 at 10:59 AM. Reason: code tags ONLY around the code, not the entire unwrapped post

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    And the point of doing this is what?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    nothing. it just tests your knowledge of the C language.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Congratulations then - you know that /**/ can be used wherever white space should be used.

    Now can you tell us whether this would work on a pre ANSI compiler?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    i dont know if it works on a pre ANSI C compiler or not.
    can u tell me some pre ANSI C compiler in use today ???

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You're going to have to do more than 4 minutes research!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    i cant spend so much time ...........
    u tell me

  8. #8
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    do you know the other solution by the way oh mighty "GOD OF C " ????

  9. #9
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you don't need any "whitespace" here except the first one
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  10. #10
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    done.
    i will use only a single comment in this solution to delimit the tokens.

    but whats the other solution. did anybody get any ideas ?

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're not even close to what your program's description is. You don't have an unsigned int. You have a pointer. You also don't have a constant pointer to a character.


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    well the example is just to show you the use of /* comments */ to delimit the tokens thats it.
    it isnt very hard to fill in the other things. if you are still not satisified then here is the EXACT solution required

    Code:
    typedef/**/struct{unsigned/**/aku;const/**/char/**/*soku;}zan;
    now tell me if you can help me to find the other solution

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well, comments technically are whitespace.


    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    well we all have figured that out by now................ but i am dying to know the other solution

  15. #15
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well if you're using comments, then none of you have it figured out, because comments are whitespace. Either that or your instructor or whoever came up with this bright idea, is wrong in their explanation of the problem. That is the problem with these types of "trick problems".


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 07:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM