c: issue with strchr(): returning wrong value? -


i'm trying code stuff within strchr unfortuantly use of strchr leading execution bugs, appears strchr in cases returning wrong value, here code:

int main(){      char* s="1/2/3/4/8/9/7";     char r[100];     char chunk2[100];     int i,jpos;      for(i=0;i<5;i++){     strcpy(r, strrev(s));     jpos = strchr(r, '/')-r;     strncpy(chunk2, r, jpos);     strcpy(r, strrev(chunk2));     } } 

what's wrong? , how can fix issue? thanks.

s string literal, strrev() tries change it, cannot on static data.

use array of characters

char s[]="1/2/3/4/8/9/7"; 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -