<HTML><HEAD><TITLE>Expressions</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
<H1><A NAME="Expressions">Expressions</A></H1><HR>
<P><B><A HREF="#Expression Subcontexts">Expression Subcontexts</A>
· <A HREF="#Classes of Expressions">Classes of Expressions</A>
· <A HREF="#Class Conversions">Class Conversions</A>
· <A HREF="#Type Conversions">Type Conversions</A>
· <A HREF="#Promoting">Promoting</A>
· <A HREF="#Balancing">Balancing</A>
· <A HREF="#Assigning and Type Casting">Assigning and Type Casting</A>
· <A HREF="#Changing Representations">Changing Representations</A>
· <A HREF="#Pointer Arithmetic">Pointer Arithmetic</A>
· <A HREF="#Reading Expressions">Reading Expressions</A>
· <A HREF="#Grouping">Grouping</A>
· <A HREF="#Operator Summary">Operator Summary</A>
· <A HREF="#Order of Evaluation">Order of Evaluation</A>
</B></P>
<P><B><A HREF="#Add Assign">Add Assign</A>
· <A HREF="#Add">Add</A>
· <A HREF="#Address of">Address of</A>
· <A HREF="#Assignment">Assignment</A>
· <A HREF="#Bitwise AND Assign">Bitwise AND Assign</A>
· <A HREF="#Bitwise AND">Bitwise AND</A>
· <A HREF="#Bitwise Exclusive OR Assign">Bitwise Exclusive OR Assign</A>
· <A HREF="#Bitwise Exclusive OR">Bitwise Exclusive OR</A>
· <A HREF="#Bitwise Inclusive OR Assign">Bitwise Inclusive OR Assign</A>
· <A HREF="#Bitwise Inclusive OR">Bitwise Inclusive OR</A>
· <A HREF="#Bitwise NOT">Bitwise NOT</A>
· <A HREF="#Comma">Comma</A>
· <A HREF="#Conditional">Conditional</A>
· <A HREF="#Divide Assign">Divide Assign</A>
· <A HREF="#Divide">Divide</A>
· <A HREF="#Equals">Equals</A>
· <A HREF="#Function Call">Function Call</A>
· <A HREF="#Greater Than Or Equal">Greater Than Or Equal</A>
· <A HREF="#Greater Than">Greater Than</A>
· <A HREF="#Indirection">Indirection</A>
· <A HREF="#Left Shift Assign">Left Shift Assign</A>
· <A HREF="#Left Shift">Left Shift</A>
· <A HREF="#Less Than Or Equal">Less Than Or Equal</A>
· <A HREF="#Less Than">Less Than</A>
· <A HREF="#Logical AND">Logical AND</A>
· <A HREF="#Logical NOT">Logical NOT</A>
· <A HREF="#Logical OR">Logical OR</A>
· <A HREF="#Minus"></A>
· <A HREF="#Multiply Assign">Multiply Assign</A>
· <A HREF="#Multiply">Multiply</A>
· <A HREF="#Not Equals">Not Equals</A>
· <A HREF="#Plus">Plus</A>
· <A HREF="#Point at">Point at</A>
· <A HREF="#Postdecrement">Postdecrement</A>
· <A HREF="#Postincrement">Postincrement</A>
· <A HREF="#Predecrement">Predecrement</A>
· <A HREF="#Preincrement">Preincrement</A>
· <A HREF="#Remainder Assign">Remainder Assign</A>
· <A HREF="#Remainder">Remainder</A>
· <A HREF="#Right Shift Assign">Right Shift Assign</A>
· <A HREF="#Right Shift">Right Shift</A>
· <A HREF="#Select">Select</A>
· <A HREF="#sizeof operator">sizeof</A>
· <A HREF="#Subscript">Subscript</A>
· <A HREF="#Subtract Assign">Subtract Assign</A>
· <A HREF="#Subtract">Subtract</A>
· <A HREF="#Type Cast">Type Cast</A>
</B></P>
<HR>
<P>You write <B>expressions</B> to determine values, to alter values stored
in objects, and to call functions that perform input and output. In
fact, you express all computations in the program by writing expressions.</P>
<P>The translator itself must evaluate some of the expressions you write
to determine properties of the program. The translator or the target
environment must evaluate other expressions prior to
<A HREF="lib_over.html#program startup">program startup</A>
to determine the initial values stored in objects with
<A HREF="declare.html#static duration">static duration</A>.
The program evaluates the remaining expressions when it executes.</P>
<P>This document describes the different
<A HREF="#Classes of Expressions">classes of expressions</A>
and the restrictions on each class. It presents the common rules for
writing all expressions, determining their types, and computing their
values. It also discusses the constraints on the
<A HREF="function.html#flow of control">flow of control</A> through
an expression.</P>
<H2><A NAME="Expression Subcontexts">Expression Subcontexts</A></H2>
<P>Within a statement or declaration, every full expression that
you write inhabits one of three contexts:</P>
<UL>
<LI>a <A HREF="function.html#test context">test context</A></LI>
<LI>a <A HREF="function.html#value context">value context</A></LI>
<LI>a <A HREF="function.html#side-effects context">side-effects
context</A></LI>
</UL>
<P>More generally, however, every full expression or subexpression
that you write inhabits one of four
<B><A NAME="expression subcontext">expression subcontexts</A></B>,
depending on its goal:</P>
<UL>
<LI>an <A HREF="#rvalue subcontext">rvalue subcontext</A>,
which includes test and value contexts
<LI>an <A HREF="#lvalue subcontext">lvalue subcontext</A></LI>
<LI>a <A HREF="#function-designator subcontext">function-designator
subcontext</A></LI>
<LI>a <A HREF="#side-effects subcontext">side-effects
subcontext</A></LI>
</UL>
<P>An <B><A NAME="rvalue subcontext">rvalue subcontext</A></B>
specifies a value that has an
<A HREF="types.html#object types">object type</A> other than an
<A HREF="types.html#Array Types">array type</A>.
You create an rvalue subcontext wherever
you need to specify a test or value to the translator,
determine an initial value prior to
<A HREF="lib_over.html#program startup">program startup</A>
or compute a value when the program executes.</P>
<P>An <B><A NAME="lvalue subcontext">lvalue subcontext</A></B>
designates an object, but its expression
can have either an object type or an incomplete type. You create an
lvalue subcontext wherever you need to access the value stored in
an object, alter the stored value, or determine the address of the
object. (If the type is incomplete, you can determine only the address
of the object.)</P>
<P>A <B><A NAME="function-designator subcontext">function-designator
subcontext</A></B> designates a function. Hence,
its expression has a function type. You create a function-designator
subcontext wherever you need to
call a function or determine its address.</P>
<P>A <B><A NAME="side-effects subcontext">side-effects
subcontext</A></B> specifies no value and designates
no object or function. Hence, its expression can have a
<A HREF="types.html#void types"><I>void</I> type</A>.
You create a side-effects subcontext when you need to cause only side
effects.</P>
<P>For example, consider the following code sequence:</P>
<PRE>
void f(int);
int x;
f(x = 3);</PRE>
<P>In the last line:</P>
<UL>
<LI><CODE>f</CODE> is in a function-designator subcontext</LI>
<LI><CODE>x</CODE> is in an lvalue subcontext</LI>
<LI><CODE>3</CODE> and <CODE>x = 3</CODE> are both in rvalue subcontexts</LI>
<LI><CODE>f(x = 3)</CODE> is in a side-effects subcontext</LI>
</UL>
<H2><A NAME="Classes of Expressions">Classes of Expressions</A></H2>
<P>Every expression that you write belongs to
one of several <B>expression classes</B>,
depending upon its form. Four of these classes are closely
associated with the four
<A HREF="#Expression Subcontexts">expression subcontexts</A>:</P>
<UL>
<LI>An <B><A NAME="rvalue expression">rvalue expression</A></B> has an
<A HREF="types.html#object types">object type</A> other than an
<A HREF="types.html#Array Types">array type</A>.</LI>
<LI>An <B><A NAME="lvalue expression">lvalue expression</A></B>
designates an object and has an object type or an
<A HREF="types.html#Incomplete Types">incomplete type</A>.</LI>
<LI>A <B><A NAME="function-designator expression">function-designator
expression</A></B> has a
<A HREF="types.html#Function Types">function type</A>
C标准函数库-----
4星 · 超过85%的资源 需积分: 0 57 浏览量
2016-09-28
14:15:02
上传
评论 1
收藏 290KB RAR 举报
张文琪2023
- 粉丝: 377
- 资源: 57
最新资源
- 238.html
- 基于C#.NET+PhantomJS+Sellenium的高级网络程序
- 基于Verilog HDL的五级流水线RISC-V CPU设计源码+报告文档(课程设计).zip
- 基于AMDavaScript模块加载器迄今为止对AMD理解最好的实现
- 基于Verilog HDL的五级流水线RISC-V CPU设计+报告文档+使用说明(高分项目).zip
- 基于 TypeScript 编写的 JavaScript 简洁 UI 库
- 基于正则匹配的 JavaScript 解密工具
- python实现基于SDN架构的网络流量监控和控制源码.zip
- 数据分析,数据可视化,numpy
- 基于 Vue3、Vite4、TypeScript/JavaScript、Tailwindcss、Vant4,开箱即用的移动端项目
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈