数组中的值没有在C中显示

问题描述 投票:0回答:0

这是我的代码

\#include \<stdio.h\>
void main() {
int opt,element;
char name\[10\]\[10\]={"Hytrogen","oxygen","Mercury"};
printf("WELCOME TO PERIODIC TABLE IMPLEMENTATION USING C LANGUAGE \\n");
printf("Please enter the atomic number of any element to view its details\\n");
scanf("%d",&opt);
printf("\\nThe entered option is %d",opt);
element=opt+1;
printf("\nAtomic numbere is : %d",element);
printf("\\nName of the element is : ");
printf(name\[element\]);  
}

我得到的输出

欢迎使用 C 语言实现周期表 请输入任何元素的原子序数以查看其详细信息 2个 输入的选项是2 原子序数是:3 元素的名称是:

为什么元素名称没有打印在最后一行“元素的名称是:??”

我试过在线编译器

arrays c printf
© www.soinside.com 2019 - 2024. All rights reserved.