Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 7: Pointers and Parameters > Function Parameters

Function Parameters

One of the most important uses of pointers (and perhaps the easiest to understand) lies in the implementation of function parameters. In this section, we'll focus on parameters and, at the same time, have a chance to check out pointers in action.

What Are Function Parameters?

A function parameter is your chance to share a variable between a calling function and the called function.

Suppose you wanted to write a function called AddTwo() that took two numbers, added them together, and returned the sum of the two numbers. How would you get the two original numbers into AddTwo()? How would you get the sum of the two numbers back to the function that called AddTwo()?

As you might have guessed, the answer to both questions lies in the use of parameters. Before you can learn how to use parameters, however, you'll have to first understand the concept of scope.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint