私はこの構造を持ち、ポインターを使用して、さまざまな構造変数の値を出力しようとしていますが、int 変数の場合は値の代わりにロケーション アドレスを出力し、char 変数の場合は結果が正しいです。
#include <stdio.h>
#include <stdlib.h>
struct calc{
int row;
int col;
int menu_name[20];
int sub_menu_name[20];
};
int main()
{
int count = 0, i = 0;
struct calc *P_calc[2];
//p_calc = (struct calc *)malloc(sizeof(struct calc)*2);
for(count; count<1; count++)
{
P_calc[count] = (struct calc *)malloc(sizeof(struct calc));
printf("Please enter the row cordinates: \n");
scanf("%d",P_calc[i]->row);
printf("Please enter the col cordinates: \n");
scanf("%d",P_calc[i]->col);
printf("Please enter the menu_name: \n");
scanf("%s",P_calc[i]->menu_name);
printf("Please enter the sub_menu_name: \n");
scanf("%s",P_calc[i]->sub_menu_name);
}
for(i; i<1; i++)
{
printf("row : %d\n",P_calc[i]->row);
printf("col :%d\n",P_calc[i]->col);
printf("menu_name: %s\n",P_calc[i]->menu_name);
printf("sub_menu_name :%s\n",P_calc[i]->sub_menu_name);
}
system("PAUSE");
return 0;
}
私を助けてください。
前もって感謝します。