"字典"未申报 [英] "Dictionary" Undeclared
本文介绍了"字典"未申报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图创造C.基本上,用户创建自己的字典,输入一个单词,然后定义字典。我已经创建其中显示词典的函数,表示各条目和它的定义。不过,我得到这个错误:
I'm trying to create a dictionary in C. Basically, the user creates the dictionary himself, inputting a word and then a definition. I've created a function where the dictionary is displayed, showing each entry and its definition. However, I'm getting this error:
错误:'词典'未声明(第一次使用此功能使用)
error: ‘dictionary’ undeclared (first use in this function)
下面是我写的code:
Here's the code that I've written:
#include <stdio.h>
void display (char *array) {
int i;
for (i=0; i<11; ++i)
printf("%s %s", dictionary[i][0], dictionary[i][1]);
}
int main(void) {
char *dictionary[10][2];
int command;
int i;
while (command != 3) {
printf ("1. Define or 2. Lookup or 3. Exit");
scanf ("%d", &command);
if (command == 1) {
for (i=0; i<11; ++i) {
printf("Please enter a word to define:");
scanf("%s\n", dictionary[i][0]);
printf("Please enter its definition:");
scanf("%s", dictionary[i][1]);
break;
}
}
if (command == 2)
display(dictionary);
}
return 0;
}
有人能解释我在做什么错了?
Can someone explain what I'm doing wrong?
推荐答案
字典
是在不同的函数的局部变量。结果
您的参数被命名为阵列
。
dictionary
is a local variable in a different function.
Your parameter is named array
.
这篇关于&QUOT;字典&QUOT;未申报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文