Originally Posted by
MiLo
I put it all in the way i understood it, and it will run for me. Its not doing what its supposed to though. It prints the %d as a %d. This is what i have done:
<...>
Did i not stick it in properly? or is it something else.
You used the wrong buffer (it's buff and not str)
This probably what you want. conio and stdout have a different behaviour. Once again, be consistent and don't mix them unless you have a good reason to do it..
Code:
#include <conio.h>
#include <stdarg.h>
#include <stdio.h>
#define EOL "\n\r"
/* Menu Printing */
void menuprn (char number[],
char str[],
...)
{
if (str != NULL)
{
char buff[512];
va_list ap;
va_start (ap, str);
vsprintf (buff, str, ap);
va_end (ap);
textcolor (WHITE);
cprintf ("%-8s ", number);
textcolor (LIGHTGRAY);
cprintf ("%s" EOL, buff);
}
}
int main (void)
{
int aces[] = { 1, 2, 3, 4 };
int tOfKind[] = { 5, 6, 7, 8, 9 };
int playerNum = 2;
menuprn ("(1)", "%-16s%8d", "Aces", aces[playerNum]);
menuprn ("(7)", "%-16s%8d", "3 of a Kind", tOfKind[playerNum]);
return 0;
}
Code:
D:\C-BOARD\M\MILO>bc proj.prj
(1) Aces 3
(7) 3 of a Kind 7