Reverse part of a linked list
Redundancy in while loops

Your while loop has a condition that never gets used because there is an if statement inside the loop that actually ends the loop.  For example:


while (count != m)
{
    ++count;
    if (count == m)
    {
        break;
    }
    prev = cur, cur = cur-&gt;next;
}



You could simplify this by merging the increment into the loop condition.  Also, I don't using the comma operator to put two statements on one line.  So I would write your loop like this:

while (++count &lt; m)
{
    prev = cur;
    cur  = cur-&gt;next;
}


And your other loop would look like this:

while (++count &lt; n)
{
    struct ListNode* temp = cur-&gt;next;
    cur-&gt;next = prev;
    prev      = cur;
    cur       = temp;
}


Use typedef

I suggest using a typedef so you don't have to use struct so much.  For example:

typedef struct ListNode {
     int val;
     struct ListNode *next;
} ListNode;


And then use just ListNode instead of struct ListNode everywhere.