This opens up an interesting discussion. If malloc fails and the program has not previously requested sufficient memory to complete execution, what other option is there than to terminate as...
Type: Posts; User: sonjared
This opens up an interesting discussion. If malloc fails and the program has not previously requested sufficient memory to complete execution, what other option is there than to terminate as...
Good question. Another good question would be what if the host system does not release allocated memory on process termination. How would you solve those two problems?
Another improvement could be...
I disagree. Look at the description of the problem from post #4 and you'll see that generating a list from a string is a very small part of the program. Also, given the utterly simple nature of the...
That's a shame. But as far as how to go about it, it is quite simple and essentially nothing changes with how a list of any other type might be managed:
#include <stdio.h>
#include <stdlib.h>
...
Are you sure you want each node in the list to represent a single character? That is a very wasteful design given that each character has at least the additional overhead of a pointer.