Skip to Content
Cクイックリファレンス 第2版
book

Cクイックリファレンス 第2版

by Peter Prinz, Tony Crawford, 黒川 利明, 島 敏博
November 2016
Beginner to intermediate
816 pages
19h 58m
Japanese
O'Reilly Japan, Inc.
Content preview from Cクイックリファレンス 第2版
88
5
章 式と演算子
y = sqrt((x=2.7, 2*x));
この文は、先ほどの例と等価になる。カンマ演算子は複数の式を1つにできる。これによ
り、
for
ループの先頭で、次の例のように、複数の変数を初期化または増分することができ
る。
int i; float fArray[10], val;
for (i=0, val=0.25; i < 10; ++i, val *= 2.0)
{
fArray[i] = val;
}
5.3
 定数式
ソースコード中の定数式は、コンパイラによって認識され、その値に置き換えられる。
置き換える定数値は、式の型で表現可能でなければならない。単純な定数が許されるとこ
ろでは定数式が使える。
定数式の演算子には他の式と同じ規則が適用される。定数式は翻訳時に評価されるので、
関数呼び出しまたは代入のような変数の値を変更する演算を含むことはできない。
5.3.1
 整数定数式
整数定数式は、整数型の定数式である。次の要素を定義するのに使う式だ。
配列のサイズ
列挙定数の値
ビットフィールドのサイズ
_Alignas
を用いた定義でのオブジェクトのアラインメント(C11
switch
文の
case
定数の値
例えば、次のように配列を定義する。
#define BLOCK_SIZE 512
char buffer[4*BLOCK_SIZE];
整数定数式には次の種類のオペランドを使うことができる。
整数、文字、列挙の定数
sizeof
式と
_Alignas
定数式の
sizeof ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Rustの練習帳 ―コマンドラインツールの作成を通してRustを学ぶ

Rustの練習帳 ―コマンドラインツールの作成を通してRustを学ぶ

Ken Youens-Clark, 中山 光樹
Unityによるモバイルゲーム開発 ―作りながら学ぶ2D/3Dゲームプログラミング入門

Unityによるモバイルゲーム開発 ―作りながら学ぶ2D/3Dゲームプログラミング入門

Jon Manning, Paris Buttfield-Addison, 鈴木 久貴, あんどうやすし, 江川 崇, 安藤 幸央, 高橋 憲一

Publisher Resources

ISBN: 9784873117812Other