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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -