添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Quote:
In function 'void menu()': // 'printf' was not declared in this scope .(these are the two errors)

Error messages also include line number where error is. It is a good idea to tell us.
As OG spotted, exact error message matters too.
struct order{ int Tents; int Chairs; int S_Tables; int L_Tables; }; // Never ';' after a '}'
case 2: Printf( " %d items rented" ); // the '%d' tells that you want to print a variable value, but you didn't gave 1 break ; Additionally, be careful about how you declare your functions:
C
void menu():If you are using a C++ compiler, this is the equivalent of
C++
void menu( void );But for C, it declares that there is a function menu that does not return anything, and takes an unknown number and types of arguments. This can lead to surprising occurrences. Consider:
Shell
[ k5054@locahost ]$ cat example.c # include <stdio.h> void f1(); void f2(long long); int main() f1(-1); f1(2.1); f2(-1); f2(2.1); return 0 ; void f1(long long l) printf( " f1: l = %lld\n" , l); void f2(long long l) printf( " f2: l = %lld\n" , l); [ k5054@locahost ]$ gcc -Wall -Wextra example.c -O0 -o example-O0 [ k5054@locahost ]$ gcc -Wall -Wextra example.c -O3 -o example-O3 [ k5054@locahost ]$ ./example-O0 f1: l = 4294967295 f1: l = 0 f2: l = -1 f2: l = 2 [ k5054@locahost ]$ ./example-O3 f1: l = -1 f1: l = 4611911198408756429 f2: l = -1 f2: l = 2 [ k5054@locahost ]$ Note that we get different output from the same program, depending on the Optimization level. In the case of no optimization, the compiler makes a guess at what the type of the parameter might be, and makes a function call, converting the actual parameter as it goes. In the case of optimization, however, the compiler is able to optimize away the funtion call, and calls printf() with the un-converted bit-patterns for (int)-1 and (double)2.1.
Bottom line - if you know your functions don't take an argument, declare them as having a void argument list, not () .
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •