Thread: structure doubt...

  1. #1
    anguished incognito54's Avatar
    Join Date
    Apr 2004
    Posts
    24

    structure doubt...

    is there any structure that can store a value (char, int, float...) and a string that is associated with that value and then whenever the string occurs in prog it is replaced with the value?
    it must be too good to be true...
    I've never felt the nausea of longing to feel nothing,
    I never wanted to cease to exist, just disappear...

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Are you familiar with how #define works?

    If so, you'll have to clarify your question...

    gg

  3. #3
    anguished incognito54's Avatar
    Join Date
    Apr 2004
    Posts
    24
    i know how it works... what i wanted to do was to make a different kind of define... the thing is, i am making a customized preprocessor just for the purpose of learning how to program in C cause i'm a real n00b... i already made my very own #include and now i'm trying to make my #define...
    I've never felt the nausea of longing to feel nothing,
    I never wanted to cease to exist, just disappear...

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    So you're making a pre-preprocessor....those are fun.

    If you're making your own #define, then you should be able to just do straight word replacement. There's no need to know if it's a char, int, float, or whatever.

    So here's a more defined problem statement:
    Find a all occurences of word A, and replace it with word B, where a word is defined as any valid C-language identifier.
    A valid C identifier is a contiguous series of only the following characters: 'A'-'Z', 'a'-'z', '0'-'9', and '_'.

    gg

  5. #5
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Quote Originally Posted by incognito54
    i know how it works... what i wanted to do was to make a different kind of define... the thing is, i am making a customized preprocessor just for the purpose of learning how to program in C cause i'm a real n00b... i already made my very own #include and now i'm trying to make my #define...
    Not to throw cold water on your desire, but if you are such a n00b why are you trying to make a program that is beyond the scope of a noob? Why not learn to program not by trying to write a program even knowledgable programmers won't do but by programs that allow you to learn the code without having to ask how to do each step and learn such advanced techniques? Maybe you should save the advanced techniques for later when you have the concept of C syntax and coding figured out.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Besides there is nothing fancy or advanced to misusing the C pre-processor. It will only teach you bad habits.

  7. #7
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    the structure of multi types exists in the c and the c++.
    you can declare it of the following way
    struct / *nameofstruct * /
    {
    declaration types
    }
    / * end; * /
    again you can a type of struct
    typedef struct
    {
    declaration variables
    }
    / *name of type * /

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubt in structure
    By karthik537 in forum C Programming
    Replies: 15
    Last Post: 01-21-2009, 03:52 AM
  2. doubt regarding C structure in linux
    By Bargi in forum C Programming
    Replies: 2
    Last Post: 01-23-2007, 06:18 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 05:48 PM