For some reason this won't compile. This isn't the first time that something hasn't worked from this book so I suspect it's a tiny typo that is messing up the whole thing. Can someone explain to me why this doesn't compile? I'm just starting to deal with strings so I don't know how to call a function from within a string.
#include <stdio.h>
main ()
{ int str_number;
for (str_number = 0; str_number < 13; str_number++)
{
printf ("%s", menutext(str_number));
}
}
/*********************************************************/
char *menutext(n)
int n;
{
static char *t[] =
{
" -------------------------------------- \n",
" | ++ MENU ++ |\n",
" | ~~~~~~~~~~~~ |\n",
" | (1) Edit Defaults |\n",
" | (2) Print Charge Sheet |\n",
" | (3) Print Log Sheet |\n",
" | (4) Bill Calculator |\n",
" | (q) Quit |\n",
" | |\n",
" | |\n",
" | Please Enter Choice |\n",
" | |\n",
" -------------------------------------- \n"
};
return (t[n]);
}
I get an error on line 15: char *menutext(n)
C:\Documents and Settings\Gary II\Desktop\cprog.c|15|error: conflicting types for 'menutext'|