simple...

Out of context: Reply #1

  • Started
  • Last post
  • 12 Responses
  • lowimpakt0

    #include
    #include

    int main(int argc, char *argv[])
    {
    int x = 1;
    char str[]="this:is:a:object:to:move...
    char *str1;

    /* hold when finished
    */
    printf("String: %s
    ", str);

    /* extract first string from string sequence */
    str1 = strtok(str, ":");

    /* loop first string after strt */
    printf("%i: %s
    ", x, str1);

    /* loop until finishied */
    while (1)
    {
    /* extract string from string sequence */
    str1 = strtok(NULL, ":");

    /* check if there is nothing else to extract */
    if (str1 == NULL)
    {
    printf("Tokenizing complete
    ");
    exit(0);
    }

    /* print string after tokenized */
    printf("%i: %s
    ", x, str1);
    x++;
    }

    return 0;

    }

View thread