Interesting bug! You forgot function name. Notice inside while-loop body following expression:
tokens = (NULL, ",'");
^
'strtok' missing
should be:
tokens = strtok(NULL, ",'");
Interesting thing is that this is not a compilation error, in fact:
tokens = (NULL, ",'");
is a valid expression which is equals to:
tokens = ",'";
(Note: NULL
has no side effects)
Read: Comma Operator: ,
The comma operator ,
has left-to-right associativity
. Two expressions
separated by a comma are evaluated left to right. The left operand is
always evaluated, and all side effects are completed before the right
operand is evaluated
.
Due to parenthesis (
)
at rhs of =
, after evaluating ,
operator right hand operand ","
is assigned to token
. And because token
never assigned NULL
so while(tokens != NULL)
never breaks, and this is the reason that you are getting ","
infinitely!