C program to split char using strtok and strchr -
C program to split char using strtok and strchr -
i have next c programme split char*
its user entred value in format "111/222". (code produce right output)
in cases , value entered "/222".
char* ptr ="/222" ; char* val1 , *val2; val1 = strchr( ptr, '/'); if ( val1 != null) val1++; val2 = strtok(ptr,"/");
myoutput :
val1 = 222
val2 = 222
i dont know how get
val1 = "" (as empty char)
val2 = 222
thanks in advance ur help!
the easiest way check if string start / or not. if then, set val1 "" , val2 have point (ptr + 1). else currently
c
Comments
Post a Comment