From the course: Advanced C Programming: Optimize Performance and Efficiency

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Solution: Incrementing a pointer

Solution: Incrementing a pointer

(upbeat music) - [Instructor] For my solution, I used two variables, f and fptr. The pointer variable is initialized at line seven, the ampersand operator is used. At line eight, the value 89 is assigned by using the asterisk operator on the pointer. Same operator is used line nine to display the value. At line 10, the increment operator is used. It prefixes the asterisks operator, which allows for the value at the address to be incremented. And there's the result. Now, say that you wanted to put the increment operator after point or variable, as in *fptr++. In this case, what you're doing is incrementing something after it's been used. But what you're incrementing is the address, not the value at the address. You'll still see the same value displayed but the pointer is incremented to a point at rubbish in memory. Again, where you put the operators important here, thanks to the order of precedence, which is the topic…

Contents