so I'm working on this project for school, but it's been a while since I've worked in C so I'm having some difficulties... any help would be appreciated.
Code:
char** tokenize (char* str, char* delims, int* arsize){
char* strptr;
// set the strptr
strptr=str;
// firstly ignore delims at start of string
while(is_delimiter(*strptr, delims)){
strptr++;
}
...
}
int is_delimiter (char needle, char* haystack){
while(*haystack){
/* if(needle=*haystack)return 1; */
if(needle==*haystack++)return 1;
}
return 0;
}
so what I wanted to do here is copy the pointer to str into a new char pointer; strptr. Compilation goes fine but on runtime I get a bad pointer exception. Seems like str (which holds a char pointer to the first char in the string) can't be copied to strptr (which is also a char*).
What am I doing wrong please? I guess it's gotta have something to do with the small difference between a Cstring and a char*, but I can't seem to figure it out...
thx in advance