String Parsing...

SephirothSephiroth Fayetteville, NC, USA
OK, I need to figure out how to parse out a string to get a command and then parameters from it. Here is what I am trying.
[code]
Pos = 0;
while(!isspace(String[Pos]))
{
Command[Pos] = String[Pos];
Pos++;
}
[/code]
Now if I sent the string "Say Hello world!" I would expect the 'Command' array to be "Say", but instead it is "Say^%$#^%". What's going on? Thanks for the help.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • : OK, I need to figure out how to parse out a string to get a command and then parameters from it. Here is what I am trying.
    : [code]
    : Pos = 0;
    : while(!isspace(String[Pos]))
    : {
    : Command[Pos] = String[Pos];
    : Pos++;
    : }
    : [/code]
    : Now if I sent the string "Say Hello world!" I would expect the 'Command' array to be "Say", but instead it is "Say^%$#^%". What's going on? Thanks for the help.
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    [blue]Soooo.... inventing a bike, eh?!..
    How about a standard:[/blue][code]
    char str [] = "Say: Hello, World!";
    char* pstr;
    char* pstrSeparators = " ,";

    if ((pstr = strtok (str, pstrSeparators)) != NULL) {
    while (pstr) {
    printf ("
    - %s", pstr);
    pstr = strtok (NULL, pstrSeparators);
    }
    printf ("
    --- DONE!");
    }
    [/code]
  • SephirothSephiroth Fayetteville, NC, USA
    Right over my head at first glance. You and your nice advanced-looking bs!@# I'm going to write something like A++ and make an OS that makes even Linux obsolete, with like 256-bit memory or something just to show you up :p! I'll check it out once I figure out what half of your code actually does.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories