Quote:
|
Originally Posted by shampaynes
Can anyone help me?
|
Numerous comments:
- Your formating style is, er, um, unique.
- Function AddData() checks for errant memory allocation, & then proceeds as if nothing wrong happens.
- You need to rethink your for-loop within function ReverseList(). Consider what happens is the list coming into this function consists of only one node.
- You need to rethink your for-loop within function FreeList(). Consider what happens is the list coming into this function consists of only one node.
- You have a syntax error in function GetOddEven(). TNode is misspelled.
- The logic within function GetOddEven() needs to be overhauled:
- Decide whether the original list is to be left intact or destroyed.
- Traverse the original list once. Check each node, & if even create a new node & add to the even list, or if odd, create a new node & add to the odd list. If the original list is to be destroyed, move each node instead of creating a new one.
- At the end of execution in main(), you potentially have three lists. Destroy each one of them.
One of the standard techniques used in troubleshooting is to reduce the code down to the simplest case which generates the error, fix the error, & gradually add more code. Generally, it is best to debug as you proceed so the task isn't quite as daunting in the end.