1-#include <stdlib.h>
2-#include <stdio.h>
3-int main()
4-{
5-
6- char **p, name[80];
7-
8- ... commands ...
9-
10- return(0)
11-}
Suppose p will store a set of names (strings), that is, on position *p will
be the variable sized "text1", position *(p+1) will be "text2" and so on.
Variable sizes are up to 80. I will do:
1-some gets(name) commands to store the several "texts" at each
iteraction;
2-execute a malloc command;
3-store name contents inside each position of p, one per address; and
4-free the pointer at the end of the program.
Question(s):
A) Is that clear my statement for you? If its,
B) How can I use the malloc command for this case? At each
iteraction/storage? One malloc for
each *p and other for the **p one?
Thanks
Andre
|