May 23, 2019 at 11:44am May 23, 2019 at 11:44am UTC
You never set head
or tail
to null, hence empty(...) will probably never return 1 and the data is inserted at an invalid position.
May 23, 2019 at 11:47am May 23, 2019 at 11:47am UTC
Use your debugger to step through the program. You'll be able to see exactly where it's crashing, and to examine the contents of the memory to see why it's crashing.
HINT: What value q->head
to have at line 36?
May 23, 2019 at 11:53am May 23, 2019 at 11:53am UTC
thank both you! I did not recognize those
May 23, 2019 at 1:24pm May 23, 2019 at 1:24pm UTC
You're welcome!
Although my advice still stands: learn to use your debugger, so that you can investigate and fix these kinds of bugs yourself .