🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.lang.c
Article #633

Re: 共用体について

#633
From: Eiji Shibata
Date: Tue, 24 Mar 1998 00:00
23 lines
1481 bytes
<6f040o$gln@alpha01.sci.hiroshima-u.ac.jp>の記事において
u0672014@alpha03.sci.hiroshima-u.ac.jpさんは書きました。

>> 明解C言語という本で勉強しています。共用体のところの演習問題で、
>> student型の配列を定義し、全員のデータを表示するプログラムを作成せよ。
>> 男性であれば体重を、女性であれば3サイズを表示することとする、
>> というのがあります。ここで女性の3サイズのデータをunionの中の
>> struct{int b; int w; int h;}に対応させることができません。

student型の配列を定義し、データを読み込んでいく。

自分で書いた質問ですが、
対応のさせ方は間違っていませんでしたが、
問題は、unionでいったんfloat型のデータを使った後、
struct型のデータを使うことができなくなることでした。逆も又しかりです。


これじゃあ union の意味ないか。

==========================================
柴田英司
広島大学
Technical Details
Message-ID: <6f7k01$g5h@ue.ipc.hiroshima-u.ac.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6f040o$gln@alpha01.sci.hiroshima-u.ac.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 106434,17e1ebf0b9e3511f
X-Google-Attributes: gid106434,public
From: u0672014@ipc.hiroshima-u.ac.jp (Eiji Shibata)
Subject: Re: 共用体について
Date: 1998/03/24
Message-ID: <6f7k01$g5h@ue.ipc.hiroshima-u.ac.jp>
X-Deja-AN: 337116858
References: <6f040o$gln@alpha01.sci.hiroshima-u.ac.jp>
Mime-Version: 1.0
Distribution: fj
Content-Type: text/plain; charset=ISO-2022-JP
Organization: Information Processing Center, Hiroshima University, JAPAN
Newsgroups: fj.lang.c