From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Passing an array to a function

Passing an array to a function - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Passing an array to a function

- [Instructor] Arrays are passed to a function either whole or each element can be passed individually. In this code, each element in the array text, at line 11, is passed to the incshow function. The function increments the character passed, and displays the result. Now the function accepts a single character argument which is what's passed at line 15. Variable text x is a single character, one element in the text array. Build and run. Hello! The incshow function doesn't alter the array, nor could it, the character passed is used within the function, then it's discarded when the function is done. In this exercise file, the entire array is passed to the incshow function at line 18. In the function at line three, you see the argument is a character variable array with empty brackets. This argument indicates that an entire array is passed. And within the function, the array is modified and output. Build and run. Hello again. In the incshow function, the array's contents are modified…

Contents