LL-K Reverse problem of linked-list

my code is generating correct output in VS code, but showing error in ide and on submitting

code link: https://ide.codingblocks.com/s/179841

during the loop, your current become NULL and you are getting seg fault when you are accessing current -> next. This is the reason ide is throwing a error.

Debugging Tip : Try debugging with gdb, you can install gdb and follow these steps to debug using it.
Commands to use gdb
g++ a.cpp -g3 gdb a
after gdb loads type
(gdb) run
Output :
Segmentation fault. 0x0040173b in reverseList
(head=@0x62fe7c: 0x0, k=3) at a.cpp:55 55 N=current->next;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.