⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node42.htm

📁 Tutorila for CPP, very good tutorial for CPP
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//FR">
<!--Converted with LaTeX2HTML 97.1 (release) (July 13th, 1997)
 by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippman, Marek Rouchal, Martin Wilck and others -->
<HTML><BLOCKQUOTE><img src="logo.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/logo.gif" ALIGN=right></A> 
<HEAD>
<TITLE>Pointeurs et op閞ateurs additifs</TITLE>
<META NAME="description" CONTENT="Pointeurs et op閞ateurs additifs">
<META NAME="keywords" CONTENT="Introduction_ANSI_C">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso_8859_1">
<LINK REL="STYLESHEET" HREF="Introduction_ANSI_C.css" tppabs="http://www.linux-kheops.com/doc/ansi-c/Introduction_ANSI_C.css">
<LINK REL="next" HREF="node43.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node43.htm">
<LINK REL="previous" HREF="node41.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node41.htm">
<LINK REL="up" HREF="node35.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node35.htm">
<LINK REL="next" HREF="node43.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node43.htm">
</HEAD>
<BODY BACKGROUND="marge.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/marge.gif" TEXT=#000000 LINK=#FF0000 VLINK=#1809BB >
<!--Navigation Panel-->
<A NAME="tex2html1674"
 HREF="node43.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node43.htm">
<IMG WIDTH="77" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="next_motif.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/next_motif.gif"></A> 
<A NAME="tex2html1670"
 HREF="node35.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node35.htm">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="up_motif.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/up_motif.gif"></A> 
<A NAME="tex2html1664"
 HREF="node41.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node41.htm">
<IMG WIDTH="96" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="previous_motif.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/previous_motif.gif"></A> 
<A NAME="tex2html1672"
 HREF="node1.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node1.htm">
<IMG WIDTH="96" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="contents_motif.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/contents_motif.gif"></A> 
<A NAME="tex2html1673"
 HREF="node174.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node174.htm">
<IMG WIDTH="59" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="index_motif.gif" tppabs="http://www.linux-kheops.com/doc/ansi-c/icons.gif/index_motif.gif"></A> 
<BR>
<B> Suivant:</B> <A NAME="tex2html1675"
 HREF="node43.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node43.htm">Diff閞ence de deux pointeurs</A>
<B> D閎ut:</B> <A NAME="tex2html1671"
 HREF="node35.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node35.htm">Les pointeurs</A>
<B> Pr閏閐ent:</B> <A NAME="tex2html1665"
 HREF="node41.htm" tppabs="http://www.linux-kheops.com/doc/ansi-c/node41.htm">Exercice</A><HR>
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><strong>Paragraphes</strong></A>
<UL>
<LI><A NAME="tex2html1676"
 HREF="node42.htm#SECTION00571000000000000000" tppabs="http://www.linux-kheops.com/doc/ansi-c/node42.htm#SECTION00571000000000000000">
Op閞ateurs <TT>+</TT> et <TT>-</TT></A>
<LI><A NAME="tex2html1677"
 HREF="node42.htm#SECTION00572000000000000000" tppabs="http://www.linux-kheops.com/doc/ansi-c/node42.htm#SECTION00572000000000000000">
Op閞ateurs <TT>++</TT> et <TT>-</TT></A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<H1><font COLOR=#1809BB><A NAME="SECTION00570000000000000000">
Pointeurs et op閞ateurs additifs</A>
</font></H1>
<P><H2><font COLOR=#1809BB><A NAME="SECTION00571000000000000000">
Op閞ateurs <TT>+</TT> et <TT>-</TT></A>
</font></H2>
<A NAME="2122">&#160;</A>
<A NAME="2100">&#160;</A>
L'op閞ateur <TT>+</TT> permet de r閍liser la somme de deux valeurs arithm閠iques,
mais il permet 間alement de r閍liser la somme d'un pointeur et d'un entier.
Une telle op閞ation n'a de sens cependant, que si le pointeur rep鑢e un
閘閙ent d'un tableau.
<P>
Soient p une valeur pointeur vers des objets de type T et un tableau dont
les 閘閙ents sont du m阭e type T&nbsp;;
si p rep鑢e l'閘閙ent d'indice i du tableau,
p + j <B>est une valeur de type pointeur vers T</B>,
qui rep鑢e l'閘閙ent d'indice i + j du tableau (en supposant qu'il existe).
<P>
Il en va de m阭e avec l'op閞ateur soustraction&nbsp;: si p rep鑢e
l'閘閙ent d'indice i d'un tableau, p - j rep鑢e l'閘閙ent d'indice i - j
du tableau (toujours en supposant qu'il existe).
Exemple&nbsp;:
<PRE>
#define N 10
int t[N];
int *p,*q,*r,*s;

p = &amp;t[0];       /*   p rep鑢e le premier 閘閙ent de t   */
q = p + (N-1);   /*   q rep鑢e le dernier 閘閙ent de t   */

r = &amp;t[N-1];     /*   r rep鑢e le dernier 閘閙ent de t   */
s = r - (N-1);   /*   s rep鑢e le premier 閘閙ent de t   */
</PRE>
<P>
La norme pr閏ise que pour r閍liser la somme ou la diff閞ence d'un pointeur
et d'un entier, il faut qu'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -