C program to split char using strtok and strchr -
I have the following for C programming for C program *
A user in its format entred value In some cases, the entered value is "/ 222"
four * ptr = "/ 222" is usually "111/222" (the correct output output code) ; Char * val1, * val2; Val1 = strchr (ptr, '/'); If (val1! = NULL) val1 ++; Val2 = strtok (ptr, "/");
myoutput:
val1 = 222
val2 = 222
How do I know < P> val1 = "" (as an empty character)
val2 = 222
Thanks in advance for ur help!
The easiest way is whether your string should start with / or not. If then, val1 is to be indicated by "" and "val2" (ptr + 1). Otherwise what you currently do
Comments
Post a Comment