In this post, we will see how to resolve C – How to split a string with delimiter when sometimes there are no values between delimiter?
Question:I am trying to split a string as follows:
I am using
,as a delimiter but since there are no values between some commas I get a segmentation fault.
What is the correct way to assign null values to consecutive commas?
Best Answer:Instead of
Here is a demonstration program.
If you have better answer, please add a comment about this, thank you!