C言語なら俺に聞け(入門篇) Part 7
■ このスレッドは過去ログ倉庫に格納されています
0233デフォルトの名無しさん
2007/02/06(火) 00:06:17以下のやり方でソース書いて実行したら一応初期化されてる
けど、unionでconst使うの?
#include <stdio.h>
typedef struct{
union UNI{
const long* plong;
const short* pshort;
}uni;
}ST_Hoge;
int main()
{
int i;
const short s_area[] = { 1, 2 ,3, 4, 5 };
const ST_Hoge st = {(long *)s_area};
for(i = 0; i < 5; i++)
printf("%d ",st.uni.pshort[i]);
putchar('\n');
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています