如何以指针数组的方式反正链表?

反转链表的题目,我想用指针数组实现,但是失败了,但是错哪了?

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* reverseList(struct ListNode* head){
if(head==NULL)
        return head;
    struct ListNode* cout[6000];
    int i=0;
    struct ListNode* p=head;
    struct ListNode* wei=NULL;
    while(p->next!=NULL)
    {
        cout[i]=p;
        i++;
        p=p->next;
    }
    wei=p;
    i=i-1;
    while(i>=0)
    {
        p->next=cout[i--];
        p=p->next;
    }
    return wei;
}

怎么个失败法啊???没啥问题啊

while(p->next!=NULL) 这里应该是p!=null,否则最后一个不会入cout。