I'm trying to understand how these things work right now and am running into a question that isn't answered in the book.
suppose that I have something like this:
Code:
.........
char line[MAXLINE],
*malloc(),
*sptr,
*strtbl[NLINES];
while((nchars = get_line (line,MAXLINE)) != EOF &&
(sptr = malloc ((unsigned) nchars +1)) != NULL )
{
strcpy (sptr, line);
strtbl[i++] = sptr;
}
.......
is it also legal to do this?:
Code:
char *line,
*sptr,
**strtbl;
while((nchars = get_line (line,MAXLINE)) != EOF &&
(sptr = malloc (nchars +1)) != NULL )
{
strcpy (sptr, line);
*(strtbl + i++) = sptr;
}
I ask because it does work just the same both ways, but it seems like *(strtbl + i++) would end up pointing to someting else?
is this legal?