sprintf.h

./lib/include/fn/sprintf.h · 897 B

From the archive h7v3.0a.tar.gz

Download the archive   « Back to the archive contents

/* primitive sprintf fn so can load 3.2 mudlib on 3.1.2MSDOS */
/* accepts only %s, used in wizard.c  match_format() */


#ifndef SPRINTF_H
#define SPRINTF_H

varargs string sprintf(string format,
                          mixed arg1,
                          mixed arg2,
                          mixed arg3,
                          mixed arg4,
                          mixed arg5) {
  string pre, print_out;
  int i;
  
  print_out = "";
  while(sscanf(format,"%s\%%s",pre,format) && i < 5) {
    if(format != "" && format[0] != 's') {
      print_out += "%";
      continue;
    }
    format = extract(format,1);
    print_out += pre + ((i == 0)
               ? arg1
               : (i == 1)
               ? arg2
               : (i == 2)
               ? arg3
               : (i == 3)
               ? arg4
               : arg5);
    i++;
  }
  return print_out + format;
}

#endif  

Site Stats

Snippets: 1791
Codebases: 571