Hi
Another question on String Function, strtok.
For strtok, here is the explanation,
http://www.cplusplus.com/ref/cstring/strtok.htmland my question follows in [b][blue]blue[/b][/blue]
Summerize what they say... is this simply to separate [b]delimiter[/b] from other deliminater...? Then, is using [b]while[/b] the only way to see its result...?
This is the trial code introduced on the site above;
[code]
/* strtok example */
#include #include int main ()
{
char str[] ="This is a sample string,just testing.";
char * pch;
printf ("Splitting string "%s" in tokens:
",str);
pch = strtok (str," ");
while (pch != NULL)
{
printf ("%s
",pch);
pch = strtok (NULL, " ,.");
}
return 0;
}
[/code]
[b]Output[/b]
Splitting string "This is a sample string,just testing." in tokens:
This
is
a
sample
string
just
testing
Comments
:
: Another question on String Function, strtok.
:
: For strtok, here is the explanation, http://www.cplusplus.com/ref/cstring/strtok.html
: and my question follows in [b][blue]blue[/b][/blue]
:
: Summerize what they say... is this simply to separate [b]delimiter[/b] from other deliminater...? Then, is using [b]while[/b] the only way to see its result...?
:
: This is the trial code introduced on the site above;
: [code]
: /* strtok example */
: #include
: #include
:
: int main ()
: {
: char str[] ="This is a sample string,just testing.";
: char * pch;
: printf ("Splitting string "%s" in tokens:
",str);
: pch = strtok (str," ");
: while (pch != NULL)
: {
: printf ("%s
",pch);
: pch = strtok (NULL, " ,.");
: }
: return 0;
: }
: [/code]
:
: [b]Output[/b]
: Splitting string "This is a sample string,just testing." in tokens:
: This
: is
: a
: sample
: string
: just
: testing
:
Correct.
Greets,
Eric Goldstein
www.gvh-maatwerk.nl
: :
: : Another question on String Function, strtok.
: :
: : For strtok, here is the explanation, http://www.cplusplus.com/ref/cstring/strtok.html
: : and my question follows in [b][blue]blue[/b][/blue]
: :
: : Summerize what they say... is this simply to separate [b]delimiter[/b] from other deliminater...? Then, is using [b]while[/b] the only way to see its result...?
: :
: : This is the trial code introduced on the site above;
: : [code]
: : /* strtok example */
: : #include
: : #include
: :
: : int main ()
: : {
: : char str[] ="This is a sample string,just testing.";
: : char * pch;
: : printf ("Splitting string "%s" in tokens:
",str);
: : pch = strtok (str," ");
: : while (pch != NULL)
: : {
: : printf ("%s
",pch);
: : pch = strtok (NULL, " ,.");
: : }
: : return 0;
: : }
: : [/code]
: :
: : [b]Output[/b]
: : Splitting string "This is a sample string,just testing." in tokens:
: : This
: : is
: : a
: : sample
: : string
: : just
: : testing
: :
:
:
: Correct.
:
:
: Greets,
: Eric Goldstein
: www.gvh-maatwerk.nl
:
:
[blue]
OK, thanks for confirming my understanding.
[/blue]