Skip to content

Instantly share code, notes, and snippets.

@halogenandtoast
Created August 19, 2010 18:36
Show Gist options
  • Select an option

  • Save halogenandtoast/538568 to your computer and use it in GitHub Desktop.

Select an option

Save halogenandtoast/538568 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void create_node(char* property_list) {
char* item;
char* list;
const char *end = property_list;
while(*end)
end++;
list = (char *) malloc(sizeof(char) * (end-property_list + 1));
memcpy(list, property_list, end-property_list);
list[end-property_list] = '\0';
item = strtok(list, "|");
while(item != NULL) {
printf("%s\n", item);
item = strtok(NULL, "|");
}
}
int main(int arc, char **argv) {
create_node("foo|bar|baz");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment