Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualSubtle_Wonders

Posted 14 February 2013 - 10:40 AM

Withdrawn due to errors on my part.


#1Subtle_Wonders

Posted 14 February 2013 - 02:48 AM

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'|

char *menutext(n)   um... where's your ;

I'm sure other people have their points too, but that was the first thing that cought my eye, and the compiler did say... that line was causing you the problem.


PARTNERS