I just happened upon you're code after googling "doubly linked list". I'm implementing my own doubly linked list for an open source project and I'm too lazy to pull out a piece of paper to draw a picture, thus seeing someone else's implementation is quite helpful.
I hope you don't mind me pointing out a small (could be huge) problem, that most casual programmers can usually ignore.
Your code causes a memory leak. This is due to using malloc in the function GetNewNode, but the allocated memory isn't freed in the end. At program termination, the memory is freed automatically...so it really doesn't matter with the small example you've given. On the other hand, if I edited the main function to insert an integer in a for loop with lots of iterations, this could starve the computer of memory resources until the program terminates.
This is evident by the output of program, valgrind, below:
$ valgrind --leak-check=full --show-leak-kinds=all ./list
To fix this, a minor edit to the ReversePrint function to free each node can fix this.
Again, hope you don't mind me pointing this out. I only wrote this for some poor undergrad or amateur programmer who happened upon this source code.
but when i used this it works just fine
Thanks in advance;
I agree. Well observed !!