after alittle more time and errors i started working on more string and pointer functions, right now im confused.
the get_nextword function is just supposed to take a string and return everything before the seperator(sep). the copy function does work so i dont get why this is crashing, its doesnt even give me any warnings (im stuck in DevC in Win XP). any ideas?Code:#include <stdio.h> #include <string.h> int main() { char temp[20] = "tes_ting"; char temp2[20] = {'\0'}; int Start = 2; get_nextword(&temp, &temp2, '_', &Start, 8); printf("%s\n\n", temp2); return 0; } int get_nextword(char *src, char *dest, int sep, int *start, int max) { char *spot; if(max == '\0') max = strlen(src); copy(&src, &dest, &start, max); spot = strchr(dest, sep); dest[*spot] = '\0'; return 0; } /* WORKING CODE...WORKING CODE...WORKING CODE...WORKING CODE...WORKING CODE...*/ int copy(char *src, char *dest, int *start, int end) { int x = 0; --*start; while(*start < end) { dest[x] = src[*start]; ++*start; ++x; } return 0; }



LinkBack URL
About LinkBacks



