This is probably because you are attempting to delete a value you that isn't in the list which will cause an access violation. You should try adding '5' to the list and then deleting '5' and it should work fine.
If you don't want the program to crash when a value is entered that is not in the list, I would highly suggest using a try catch block to catch an exception. A nice tutorial on how to add try catch blocks to your program can be found here:
Ah, so you mean when one inputs data, the inputted isn't accepted or isn't saved? Something like that, you mean? How do i change that? What should i change, arrange, delete or add to my code? Please suggest what you think should be. Guide me please thanks.
So now, you get the feeling that I didn't code any of the codes' lines? If that is your choice, well then do so, I won't stop you really. I need not to look at some C++ tuts because I have done them so, before asking here in this forum. It seems like this isn't of any help, might as want to look others now. Thanks for your time dude. I was asking for your help to guide me to what you were saying but then this? Thanks alot.
Just wrote a big write up here but then realized something that is probably causing most of your frustration. You never check to make sure the current pointer isn't null before you access a pointer in the struct. Almost guaranteed to get a seg fault or access violation at some point if you don't error check for a null pointer. It's probably the most frustrating thing to learn when dealing with pointers in C/C++ and something that pretty much all C/C++ programmers struggle with initially.
Example, you do check for the current pointer to be null in your loop, but then you proceed to do q->next->data. If q is not null the loop will engage, but if the child is null, this will result in a seg fault/access violation (depending on compiler). Always check for null before accessing a member within a struct, and you have to treat internal pointers to the same type of struct as it's own struct.
I'm assuming this project forbids using an OOP approach or the class is pre-OOP, otherwise this whole design should be scrapped for an object based solution.