Thanks keskiverto ,you realy helped me solving my problem ....
i have a question if you plz tell me how to make my code exception safe i'll be realy very thankfull to you...
Any suggestions to make this code even better....???plz tell me must...
If a function has to modify a variable of the caller, then it has three options: return value, reference parameter, and a pointer. Reference is a feasible option here.
You do have other issues too.
* You main() keeps track of both the head and tail of your list. It would be better, if you had a genuine list type that tracks the details.
* Your insert() function does two tasks: ask for input and insert node. Follow the mantra: one function, one task.
* You don't deallocate memory appropriately.
* stdafx.h and system() have standard languages alternatives.