gpt4 book ai didi

c - 尝试使用结构从数组访问菜单名称...出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 07:29:17 24 4
gpt4 key购买 nike

<分区>

我有一个菜单和子菜单。我创建了一个结构,其中我在数组中存储菜单和子菜单名称。尝试将它们打印出来,但我觉得我哪里错了。

#include <stdio.h>
#include <stdlib.h>

struct calculator
{
int x_loc;
int y_loc;
char main_menu[15];
char sub_menu[15];
char icon_title[100];
};

char *main_menu_names[3] = {"Link_1", "Link_2", "Link_3"};
char *sub_menu_names[3] = {"Sub_Link_1", "Sub_Link_2", "Sub_Link_3"};

struct calculator info = {219, 120, main_menu_names, sub_menu_names, "Title"};

int main()
{
printf("X location: %d\n",info.x_loc);
printf("Y location: %d\n",info.y_loc);

printf("Menu Name: %s\n",info.main_menu);
printf("sub menu: %s\n",info.sub_menu);
printf("icon_title: %s\n",info.icon_title);

system("PAUSE");

return 0;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com