`
`
`
`C Programming Guide Second Edition.
`Copyright © 1983, 1985 by Que Corporation.
`
`First Edition pub li shed 1983. Second Edition 1985.
`
`All rights reserved. Printed in the United States of America. No part
`of this book may be used or reproduced in any form or by any
`means, or stored in a data base or retrieval system, without prior
`written permission of the pub li sher except in the case of brief quo (cid:173)
`tations embod ied in critical articles and reviews. Making copies of
`any part of this book for any purpose other than your own personal
`use is a vio lation of United States copyright laws. For information,
`address Que Corporation, 7999 Knue Road , Indianapolis, Indiana
`46250.
`
`Library of Congress Catalog No.: LC 85-60689
`ISBN 0-88022 - 157- 7
`
`Editor
`Virginia Noble, M.L.S.
`
`Editorial Director
`David F. Noble, Ph.D.
`
`Technica l Editor
`Chris DeVeney
`
`PALO ALTO NETWORKS Exhibit 1029 Page 2
`
`
`
`C PROGRAMMING GUIDE, 2nd Edition
`
`Th erefore, a function declaration gives us just enough information
`:o know what type of data a function returns, whereas a function
`definition tells us how that data type is actually produced. The dif(cid:173)
`ference between a function declaration and definition is not only a
`fi ne one, but also an important one.
`
`Declarations give you a glimpse. (No storage is allocated for the
`compi ler to examine.) Definitions let you study the whole picture.
`(Storage is allocated.)
`
`Argument List
`
`An argument list contains the variables that pass to the function
`any information needed to perform the function's task. The argu(cid:173)
`ment list may contain zero or more arguments. In the examples
`presented thus far, we have seen main() use no arguments,
`three arguments, and
`volume( length, height, width) use
`cube(number) use one argument.
`
`Whether a function needs an argument depends on the purpose of
`the function. A function that requires "outside" help probably
`needs an argument list. If the function is self-contained and needs
`no information other than what the function creates itself, no ar(cid:173)
`gument list is necessary. (You will learn later in this chapter why no
`list is needed.)
`
`Argument Declarations
`
`Each variable in the argument list of a function must have an ar(cid:173)
`gument declaration. If no argument list is provided for a function,
`no argument declaration is needed. Now let's compare the main()
`and cube() functions in code fragment 3.3.
`
`main()
`
`main()
`c
`
`versus
`
`cube()
`
`int cube(number )
`int number;
`c
`
`.
`}
`Although main() has not needed any arguments thu\ far, cube()
`needs to know the number that is to be cubed. Because a number
`is " handed" to the cube () function from "outside" itself, cube ()
`
`Code fragment 3.3.
`
`/~
`
`int cut
`int nun
`c
`
`int vo
`i nt 1, I
`c
`
`Code fragment 3.4.
`
`PALO ALTO NETWORKS Exhibit 1029 Page 3
`
`
`
`WRITING YOUR OWN FUNCTIONS
`
`67
`
`needs to know what type of data it has just received. This com (cid:173)
`muni cation is the purpose of the argument declarations.
`
`Any variable in an argument list that is not exp licitly declared de(cid:173)
`fau lts automatica lly to an int; such a declaration is known as a de (cid:173)
`fault argument declaration. To avoid future problems, however,
`you shou ld develop the habit of exp licitly declaring a// arguments
`in a function call, even when they are integer variables. You are not
`as li kely to forget to declare noninteger data types if you declare
`all variabl es. Therefore, you shou ld ignore the default and declare
`al l fu nction arguments. In the program examples, all arguments are
`declared explicitly, even when they are integers.
`
`A semicolon fo ll ows each line of an argument list declaration, as
`shown in code fragm ent 3.4.
`
`I* right *I
`
`I* wrong *I
`
`int cube (number)
`I* note semicolon *I
`int number;
`c
`
`int cube(number )
`I* semicolon missing *I
`int number
`c
`
`int volume( I , h, w)
`int l, h,w;
`c
`
`int volume( I , h, w)
`I* not a comma *I
`intI, h,w,
`c
`
`Code fragment 3.4.
`
`For the cube( l function, a semicolon follows the single argument
`declaration. For vo lume( l, we have declared I, h, and w to be in (cid:173)
`tegers and grouped them into one argument declaration. The last
`argument in the group, w, is followed by a semico lon. Omitting the
`semicolon or substituting a comma is unacceptable and will pro(cid:173)
`duce an error when the program is compiled .
`
`(If you are familiar with the concept of a stack, you probably already
`know why argument declarations are necessary. These declara(cid:173)
`tions tell the compiler how many bytes must be popped off the
`stack to "fill in " the variables that are being passed to the function .)
`
`Finally, the argument declarations must occur before the opening
`brace of the function body. If we stretch th ings a bit, we can view
`
`PALO ALTO NETWORKS Exhibit 1029 Page 4
`
`
`
`PALO ALTO NETWORKS Exhibit 1029 Page 5