Pointer pointer to pointer
Duplicate:
I have a question about C and pointers.
I know when I will need a pointer, and even when I might need a pointer to a pointer. For example, if I had a linked list and I wanted to write a function that would remove an item from that list, for that I would need to send a pointer to the head pointer of the list.
How about pointer to pointer to pointer? Will there ever be a situation when it is needed? Extra points if you have some sample code for me to circle around.
a source to share
Pointers are arrays in a sense. Here's a simple scenario. Let's say you've built a text editor. Rows and columns are dynamic.
You can have an "array" of strings, and since they are dynamic, it will be a pointer. Then your columns will be dynamic as well and can be contained within your line array. So essentially:
char **lines;
You will need to line up your line first before adding symbols, but this can provide very rough editor tools.
lines = malloc(num_of_lines_in_my_file);
lines[0] = malloc(num_of_chars_for_line_1);
Certainly not pretty code, but hopefully it helps a little to answer the question.
a source to share