If you're starting fresh - why start with c? I'd recommend you jump straight to c++ or c#.
And no - you don't need to know c to learn c++.
If you're starting fresh - why start with c? I'd recommend you jump straight to c++ or c#.
And no - you don't need to know c to learn c++.
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.
His compiler reads it just fine. The error says "conflicting types for 'menutext'". It's complaining that menutext was implicitly declared to return int, but is defined to return char *.
I'm not saying that anyone should use K&R style C, but that's not the cause of the problem here.
His compiler reads it just fine. The error says "conflicting types for 'menutext'". It's complaining that menutext was implicitly declared to return int, but is defined to return char *.
I'm not saying that anyone should use K&R style C, but that's not the cause of the problem here.
This I can accept. Thank you sir. As stated before, you are a well inteligent human being and I'm glad I learned something from you.
Also anyone that reads this and needs a good c reference online that free and up-to-date I've found http://publications.gbdirect.co.uk/c_book/ to be a great help.