私はしようとしましたが、文字があったはずの整数があります。ご協力いただきありがとうございます。問題のある部分は13行目です。cの配列構造のメンバの文字を参照する方法は?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct y{
char name1[30];
char name2[30];
} y;
void x(y *array){
int i;
for (i=0;i<2;i++)
printf("%d",array[i].name1[0]); /*<- Why is this integer?*/
}
int main()
{
y array[2]={
{ "apple", "battle"},
{ "cup", "dog" },
};
x(array);
return 0;
}
文字を表示するには "%c"形式を試してください。または単に 'putchar' –