How Do I Make This Hard to Misuse?
Posted Apr 2, 2008 4:27 UTC (Wed) by
xbobx (guest, #51363)
In reply to:
How Do I Make This Hard to Misuse? by im14u2c
Parent article:
How Do I Make This Hard to Misuse?
True, for that specific case it is better the other way around.
But suppose you have a function such as:
void print_strings(FILE *stream, int num_strings, const char **list) {
int i;
for (i = 0; i < num_strings; i++) {
fputs(list[i], stream);
}
}
In this case, the assembly for this function will push stream once, then just push/pop n pointers to strings onto the stack and call fputs to print all of the strings. One could imagine that this would be useful when, say, implementing fprintf or other similar higher-level functions which all output to the same FILE *.
(
Log in to post comments)