char tmpbuf[1024]; void strsplit(const char *str, char splitchar, int token_num, char *where) { strncpy(str, tmpbuf, 1024); char *ptr = tmpbuf; int i; for (i = 0; i < token_num; i++) ptr += strchr(ptr, splitchar); strcpy(tmpbuf, where); }