compilation problems: void value not ignored as it ought to be

From: Ground Zero Enterprises (zero@baker.cnw.com)
Date: 07/07/96


I am getting problems compiling in a function I wrote called parse_prompt 
in comm.c that is called form make_prompt.  It is supposed to use another 
function (replace_str) to replace all %<character> to thier repective values 
in the prompt line.  The replace_str function worked perfectly in a 
 test program that did basically the same thing as parse prompt does 
(used for the same way to loop through a string)  Here are the compilation 
errors and fucntions: 

make ../bin/circle
make[1]: Entering directory `/home/z/zero/circle/src'
gcc -c -g -O -Wall -fno-strict-prototypes  comm.c
comm.c: In function `parse_prompt':
comm.c:850: void value not ignored as it ought to be
comm.c:851: void value not ignored as it ought to be
comm.c:852: void value not ignored as it ought to be
comm.c:853: void value not ignored as it ought to be
comm.c:854: void value not ignored as it ought to be
comm.c:855: void value not ignored as it ought to be
comm.c:856: void value not ignored as it ought to be
comm.c:857: void value not ignored as it ought to be
make[1]: *** [comm.o] Error 1
make[1]: Leaving directory `/home/z/zero/circle/src'
make: *** [default] Error 2

parse_prompt:

void parse_prompt(char *prompt, struct descriptor_data *d)
{
  char hp[10], ma[10], mv[10], mxhp[10], mxma[10], mxmv[10], iv[10], exp[10];

  sprintf(hp, "%d", GET_HIT(d->character));
  sprintf(ma, "%d", GET_MANA(d->character));
  sprintf(mv, "%d", GET_MOVE(d->character));
  sprintf(mxhp, "%d", GET_MAX_HIT(d->character));
  sprintf(mxma, "%d", GET_MAX_MANA(d->character));
  sprintf(mxmv, "%d", GET_MAX_MOVE(d->character));
  if (GET_INVIS_LEV(d->character))
    sprintf(iv, "%d", GET_INVIS_LEV(d->character));
  else
    sprintf(iv, "%d", -1);
  sprintf(exp, "%ld", GET_EXP(d->character));

  for(; replace_str(prompt, "%h", hp) > 0;);  <-- line 850
  for(; replace_str(prompt, "%H", mxhp) > 0;);
  for(; replace_str(prompt, "%m", ma) > 0;);
  for(; replace_str(prompt, "%M", mxma) > 0;);
  for(; replace_str(prompt, "%v", mv) > 0;);
  for(; replace_str(prompt, "%V", mxmv) > 0;);
  for(; replace_str(prompt, "%i", iv) > 0;);
  for(; replace_str(prompt, "%x", exp) > 0;);
}

replace_str:

int replace_str(char *source, char *pattern, char *replace) {
  char buf[5000] = {'\0'};
  char *ptr;
  int len;

  if ((ptr = (char *)strstr(source, pattern)) == NULL)
    return 0;

  ptr += strlen(pattern);  
  len = ((char *)ptr - (char *)source) - strlen(pattern);

  strncpy(buf, source, len);
  strcat(buf, replace);
  strcat(buf, ptr);
  strcpy(source, buf);
  return 1;
}


Thanks to anyone who can help,
Chris



This archive was generated by hypermail 2b30 : 12/07/00 PST