Article View: fj.lang.c
Article #345Re: 教えてください。
From: keizi kounoike
Date: Sat, 18 Apr 1998 00:00
Date: Sat, 18 Apr 1998 00:00
75 lines
3157 bytes
3157 bytes
鴻池といいます。
>小野田@NTTソフトウェア です。
(中略)
>
> ただ、X3J11/88-159(古い文献だけど)の3.1.2.5にでてくる、
>
> An array type describes a contiguously allocated nonempty set of
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>objects with a particular member object type, called the element
>^^^^^^^
>type.
>
>ってどう解釈すればいいんだろう?
># 'contiguously' と 'nonempty' がダブルででてくる...
>
上の文について以下のプログラムを実行させたところ
---------------test.c--------------------------
#include<stdio.h>
main()
{
struct test{
int x;
char y;
} t1,t2,array[1];
struct test *s;
int *sx;
char *sy;
int i;
for(i = 0;i < 2;i++){
(i == 0)? (s = &t1):(s = &t2);
(i == 0)? (sx = &t1.x):(sx = &t2.x);
(i == 0)? (sy = &t1.y):(sy = &t2.y);
printf("t%d_address = %p\n",i+1,s);
printf("t%d.x_address = %p\n",i+1,sx);
printf("t%d.y_address = %p\n",i+1,sy);
}
for(i = 0;i < 2;i++){
s = &array[i];
sx = &array[i].x;
sy = &array[i].y;
printf("array[%d]_address = %p\n",i,s);
printf("array[%d].x_address = %p\n",i,sx);
printf("array[%d].y_address = %p\n",i,sy);
}
return 0;
}
---------------------------------------------
出力結果
t1_address = 0x253f4e0
t1.x_address = 0x253f4e0
t1.y_address = 0x253f4e4
t2_address = 0x253f4d8
t2.x_address = 0x253f4d8
t2.y_address = 0x253f4dc
array[0]_address = 0x253f4d0
array[0].x_address = 0x253f4d0
array[0].y_address = 0x253f4d4
array[1]_address = 0x253f4d8
array[1].x_address = 0x253f4d8
array[1].y_address = 0x253f4dc
-----------------------------------------------
となりました。これより上の文は,配列は連続した空でないオブジェクトの集合を表
す。ここで,空でないオブジェクトとは,そのオブジェクトを構成するのに(この言
語がこのマシン上で)必要なメモリサイズであり,その中にパディングを含む含まな
いは問わない。と解釈しましたが。
ただ,只今C勉強中なので,上の例が適切であるかどうかは全く自信はありません。
Technical Details
Message-ID:
<6h9l0d$rku$1@news.naruto-u.ac.jp>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01bd669a$64962480$75910e0a@gxi117.tsi.co.jp><35337724.A71606CE@mail.raidway.ne.jp><01bd6801$31a513c0$75910e0a@gxi117.tsi.co.jp><3534D0D1.7453FEE@mail.raidway.ne.jp> <6h409o$9fa@md1.mie.sharp.co.jp><MITS.98Apr17095433@ipsgw.ips.ntts.co.jp><6h73ub$p0d@md1.mie.sharp.co.jp> <MITS.98Apr17190842@ipsgw.ips.ntts.co.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 106434,fc71488cf5570b81 X-Google-Attributes: gid106434,public From: "keizi kounoike" <kounoike@naruto-u.ac.jp> Subject: Re: 教えてください。 Date: 1998/04/18 Message-ID: <6h9l0d$rku$1@news.naruto-u.ac.jp> X-Deja-AN: 345290434 Content-Transfer-Encoding: 7bit References: <01bd669a$64962480$75910e0a@gxi117.tsi.co.jp><35337724.A71606CE@mail.raidway.ne.jp><01bd6801$31a513c0$75910e0a@gxi117.tsi.co.jp><3534D0D1.7453FEE@mail.raidway.ne.jp> <6h409o$9fa@md1.mie.sharp.co.jp><MITS.98Apr17095433@ipsgw.ips.ntts.co.jp><6h73ub$p0d@md1.mie.sharp.co.jp> <MITS.98Apr17190842@ipsgw.ips.ntts.co.jp> X-Server-Date: 18 Apr 1998 07:33:33 GMT Content-Type: text/plain; charset="iso-2022-jp" X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Naruto University of Education, Tokushima, Japan. Mime-Version: 1.0 Newsgroups: fj.lang.c