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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Understanding arrays2m 59s
-
(Locked)
Working with arrays3m 5s
-
(Locked)
Modifying arrays3m 11s
-
(Locked)
Passing an array to a function3m 17s
-
(Locked)
Working multi-dimensional arrays3m 2s
-
(Locked)
Building a structure3m 23s
-
(Locked)
Nesting structures2m 56s
-
(Locked)
Creating an array of structures2m 28s
-
(Locked)
Sending a structure to a function3m 36s
-
(Locked)
Understanding a union2m 47s
-
(Locked)
Challenge: Presidents of the U.S.A.1m 38s
-
(Locked)
Solution: Presidents of the U.S.A.2m 52s
-
-
-
-
-
-