J
James Lee
Hi,
char **ipaddress;
ipaddress = malloc(N * sizeof(char*));
for (i=0; ;i++) {
ipaddress = fxn_that_returns_pointer_to_char;
}
Here, I learned that I don't have to specify N. I can simply do:
ipaddress = malloc(sizeof(char*));
And everything works fine. I guess you just give it the first address
of pointer-to-char and that's all you need to do? I've always thought
that you have to specify how many pointer-to-chars as a lot of
examples do. Any drawback to not specifying N? In my case, I don't
know what N is. FYI, fxn_that_returns_pointer_to_char takes care of
allocating memory for chars.
Thanks!
-j.
char **ipaddress;
ipaddress = malloc(N * sizeof(char*));
for (i=0; ;i++) {
ipaddress = fxn_that_returns_pointer_to_char;
}
Here, I learned that I don't have to specify N. I can simply do:
ipaddress = malloc(sizeof(char*));
And everything works fine. I guess you just give it the first address
of pointer-to-char and that's all you need to do? I've always thought
that you have to specify how many pointer-to-chars as a lot of
examples do. Any drawback to not specifying N? In my case, I don't
know what N is. FYI, fxn_that_returns_pointer_to_char takes care of
allocating memory for chars.
Thanks!
-j.