All pastes #2056591 Raw Edit

Stuff

public text v1 · immutable
#2056591 ·published 2011-05-11 06:28 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]) {
  char buf[256];
  char ptr[256];
  char *x, *y, *z, *v;

  strcpy(buf, "test string 1");
  strcpy(ptr, "some,comma,delimited,values");
  for (x = strtok_r(buf, " ", &z); x; x = strtok_r(NULL, " ", &z)) {
    printf("x is [%s]\n", x);
    for (y = strtok_r(ptr, ",", &v); y; y = strtok_r(NULL, ",", &v)) {
      printf("y is [%s]\n", y);
    }
  }
}