Designing a string tokenizers

sir I do not understand two points.
the first: why do you in the sequential function calls pass a null as a parameter not a whole string as the first time?
and second point: the corner case where you made a condition to check whether input is null or not to make the while loop in main function terminates?

Hey @mzk1994

we are passing NULL inside strtok function becuase we have already passed str once(the very first function call where we passed str) and we want to use the same instead of reinitilaising it (if we pass str again in place of NULL then we will keep getting same result again n again becuase it will get reinitialised again n again)

Yes , it will terminate in main function as we are returning null from strtok function. So ptr will be having null and hence while condition won’t be satisfied so it won’t execute.

@mr.encoder stop copy n paste

This explanation was by @aman212yadav

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.