All pastes #371938 Raw Edit

Unnamed

public c v1 · immutable
#371938 ·published 2007-02-25 19:37 UTC
rendered paste body
// Split a line up by spacesvoid handleLine(char line[], int fileIndex) {	char* tok;	int offset = 0;	while((tok = strsep(*(&line+offset)," ")) != NULL) {		printf("Token: %s\tOffset: %d\n",tok,offset);		offset = offset+(strlen(tok)*sizeof(line));	}}// Produces a segmentation fault - gives funky results if I replace strsep with strtok (i.e. works fine for first few 'words' and then seg faults