Parsing a String... ??

This is a discussion on Parsing a String... ?? within the C Programming forums, part of the General Programming Boards category; I think maybe I'm just dumb today but then... maybe not. Heh... I've read a bunch of things so far ...

  1. #1
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147

    Question Parsing a String... ??

    I think maybe I'm just dumb today but then... maybe not. Heh...

    I've read a bunch of things so far and have a basic understanding of the built-in C string functions. However, I guess you could say I'm confused on a particular concept.

    <select><option selected>New Game<option>Continue<option>Quit</select>

    No, I'm not writting a new HTML display program.

    Now, here's the problem. I want to take that particular string (defined simply as, a char *). Then, I want to break it up using the tags and organize the data.

    Now, here's the question. Should I store the names between the tags in an array? Like, the number of the first option is associated with the characters following it up until the next '<' character.

    I figure ever time I encounter a '<' character I should compare the next characters to either 'option' or '/select'. If it's 'option', I would increment the number of options by one and then associate that number with characters between the '>' and '<' characters.

    Or am I making this way more complicated than it needs to be?

    Help??

    Thanks...

    P.S.
    I just thought of this also (wow, I do feel dumb today!). The array that stores the numbers... should I not store the numbers at all and just simply store a series of strings and than use the array indicies to acsess the string data?
    Last edited by leeor_net; 07-04-2004 at 11:08 PM.
    - Leeor

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I don't see a reason to keep an array of char *'s unless you will need them later on. The array of indicies is simple, and serves the purpose.
    Last edited by skorman00; 07-04-2004 at 11:32 PM.

  3. #3
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147

    Heh

    Ya know... I think I'm just tired because like 10 mins after I posted this I thought of 4 solutions... each one was better than the next so I sorta gave up the question....

    As I said... I do feel dumb today! Fatigue can cause a lot of problems with ones mind...



    Leeor...
    - Leeor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 05:05 AM
  2. String parsing
    By broli86 in forum C Programming
    Replies: 3
    Last Post: 07-03-2008, 06:06 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21