•      Sign In
• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

### #ActualSubtle_Wonders

Posted 14 February 2013 - 10:41 AM

Withdrawn due to errors in my part.

### #1Subtle_Wonders

Posted 14 February 2013 - 03:51 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.

As already mentioned, his code is a valid C90 function definition written in K&R style. It's not a variable.

Yup, I did read that.  Here, let me show you: "I'm sure other people have their points too...".  And I'm very much aware of it not being a varable because I didn't tell him to move it into a function.

http://opencbp.sourceforge.net/en_US.ISO8859-1/books/opencbook/func.prototypes.html

So we can assume that in raw english, he's using a depreciated, if not completely discontinued mannerism of coding style. His compiler and his code method are not alligned.  This means, he has a syntex error as pointed out in my quote. He could either update the syntex, or what I agree with from some of the other statements is move into C++.  It's backwards compatible and gives you OOD options as well.

You seem like a well inteligent human being King.  I would be interested in seeing what other skills you have; maybe even learn something from you.

PARTNERS