yep, another whois newbie
my problem, I think, is that I dont know how to properly declare a char *buf statement, and to use an array...
I must apoligize, I'm just learning c
and here is the errors generated at compile:
act.informative.c: In function `do_whois':
act.informative.c:1148: warning: excess elements in array initializer
act.informative.c:1148: warning: (near initialization for `immlevels')
act.informative.c:1154: warning: `buf' might be used uninitialized in this function
here is my do_whois code from act.informative.c:
ACMD(do_whois)
{
const char *immlevels[LVL_IMPL - (LVL_IMMORT-1)] = {
"[Immortal]",
"[God]",
"[Builder]",
"[Grgod]",
"[Implementor]",
};
struct char_data *victim = 0;
struct char_file_u tmp_store;
skip_spaces(&argument);
char *buf;
if (!*argument) {
send_to_char(ch, "Who?\r\n");
} else {
CREATE(victim, struct char_data, 1);
clear_char(victim);
if (load_char(argument, &tmp_store) > -1) {
store_to_char(&tmp_store, victim);
*buf = '\0';
if (GET_LEVEL(victim) >= LVL_IMMORT)
sprintf(buf + strlen(buf), "%s %s %s\r\n", immlevels[GET_LEVEL(victim)-LVL_IMMORT], GET_NAME(victim), GET_TITLE(victim));
else if (GET_LEVEL(victim) < LVL_IMMORT)
sprintf(buf + strlen(buf), "Level %d %s- %s %s\r\n",
GET_LEVEL(victim), CLASS_ABBR(victim), GET_NAME(victim), GET_TITLE(victim));
send_to_char(ch, buf);
} else {
send_to_char(ch, "There is no such player.\r\n"); }
free(victim);
}
}
could anyone explain how to declare/fix these?
thanks!
ben
________________________________________________________________
Sign Up for Juno Platinum Internet Access Today
Only $9.95 per month!
Visit www.juno.com
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/26/03 PDT