[ create a new paste ] login | about

Link: http://codepad.org/FZmK4usU    [ raw code | output | fork ]

arunksaha - C++, pasted on Apr 18:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <string.h>

int main() {

    char line[] = "lol | omg | bbq";
    enum{ MAXARGS = 10 };
    char const *commandstrings[MAXARGS];

    int i = 0;
    char * commandstr = strtok(line,"|");

    while(commandstr != NULL){
        commandstrings[i] = commandstr;
        printf("%s \n",commandstrings[ i ]);
        i++;
        commandstr = strtok(NULL,"|");
    }

    printf("first parsing complete!");
}


Output:
1
2
3
4
lol  
 omg  
 bbq 
first parsing complete!


Create a new paste based on this one


Comments: