Hack Forums
[C] ternary operator - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] ternary operator (/showthread.php?tid=5768912)



ternary operator - terribleopsecisterrible - Dec 15, 2017

i am having trouble understanding this statement using a ternary operator found in the partition method of the quicksort alg. what is the longer equivalent of this statement (not using ternary operator)?


Code
i = (i == NULL) ? l : i->next;

thanks in advance.


RE: ternary operator - 0xDEAD10CC - Dec 15, 2017

Code
if (i == NULL) i = l;
else i = i->next;