Thread: typedef

  1. #16
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    comments get converted to whitespace after the compiler goes to work.
    in this problem the source file shouldnt contain any whitespace when viewd with an editor .thats how the question should be interpreted.
    thats it .

    oh and by the way,white space characters are defined as blanks (spaces), horizontal and vertical tabs, newlines, carriage returns and formfeeds ONLY
    Last edited by abhi_86; 04-03-2007 at 07:04 AM.

  2. #17
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by abhi_86 View Post
    comments get converted to whitespace after the compiler goes to work.
    wrong. comments get converted to whitespace by the preprocessor. as the name suggests that runs before the compiler.
    Kurt

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The standard defines comments as whitespace.
    3. The source file is decomposed into preprocessing tokens6) and sequences of
    white-space characters (including comments).
    Preprocessing tokens can be separated by white space; this consists of
    comments (described later), or white-space characters (space, horizontal tab, new-line,
    vertical tab, and form-feed), or both.
    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    well ok. has any of the C gurus come up with the answer yet ???

  5. #20
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    If they have I don't think they want you to just take it and turn it in for a grade...

  6. #21
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    For your information i am not even a student of computer science !!! Whatever i am learning is out Of pure interest.
    And if i was really looking for answers to an assignment i would have asked for the solutions from my seniors

  7. #22
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You can compress this
    Code:
    typedef/**/struct/**/{unsigned/**/*aku;char/**/*soku;}zan;
    to
    Code:
    typedef/**/struct{unsigned*aku;char*soku;}zan;
    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".
    I don't think your code solves that at all. First of all, it doesn't mention a typedef anywhere [edit] (which is kind of ironic given the title of this thread) [/edit], so you could use
    Code:
    struct{unsigned*aku;char*soku;}zan;
    Secondly, soku is supposed to be a constant pointer to char. Thirdly, your code doesn't define a type called "zan", it defines an anonymous type and creates an instance of it called zan. Recall that you can name a struct like so:
    Code:
    struct name_t {
    };
    I personally think that assignments (or whatever) like this are stupid. Who would want to do that in reality?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #23
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    Sorry, I didn't mean to offend you. But if you think about it, showing up and asking for the solution after saying that you don't want to put any time into research *and* being snippy about it doesn't encourage people to help you.

  9. #24
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    well i have put enough research into it. but still no progress.
    so has andbody found out the answer ????

  10. #25
    Registered User
    Join Date
    Mar 2007
    Posts
    28
    Quote Originally Posted by abhi_86 View Post
    well i have put enough research into it. but still no progress.
    so has andbody found out the answer ????
    Why don't you think about the "answer"...

    looks like damn tricky useless college question or assignment or whatever it's.

  11. #26
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by m0ntana View Post
    looks like damn tricky useless college question or assignment or whatever it's.
    I wouldn't say useless. It's probably meant to shed light on the manner in which the compiler tokenizes its input. A rather obscure way of imparting that knowledge, but it wouldn't be the worst I've seen.

  12. #27
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    I shall end this useless discussion by quoting the important passage from K&R:

    Blanks, horizontal and vertical tabs, newlines, formfeeds and comments as
    described below (collectively, ``white space'') are ignored except as they separate tokens.
    Some white space is required to separate otherwise adjacent identifiers, keywords, and
    constants. If the input stream has been separated into tokens up to a given character, the next token is the
    longest string of characters that could constitute a token.

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