Had a quick question, maybe someone out there has dealt with
already..
When I was writing the oasis interface for the path information
(path editor), I had a few situations where I generated a string in the
following fashion:
sprintf(buf,"1) Time: "
"2) Type: "
"3) Action: ",
parse_time(),
parse_type(),
parse_action());
Wel, something like that - the parse_* functions are all of my
own making, and all return a string pointer... now, i know (and happy
mister compiler bitches) not to return a local pointer (a parse function
with buf[SIZE] defined), and if I use a single global buf (like, buf),
then things get messy... well in any case, is this the 'correct' style...
char *one_of_my_functions(int nothing) {
char mybuf[SIZE];
switch(nothing) {
case 1:
sprintf(mybuf,"NOTHING IS ONE");
break;
case 2:
sprintf(mybuf,"NOTHING IS TWO");
break;
default:
sprintf(mybuf,"DieDieDie!!!");
}
return strdup(mybuf);
}
OR is there something prettier that I'm overlooking...
PjD
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST