© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
S. DmitrovićModern C for Absolute Beginnershttps://doi.org/10.1007/979-8-8688-0224-9_44

44. Where to Use Pointers?

Slobodan Dmitrović1  
(1)
Belgrade, Serbia
 

In this chapter, we discuss several pointers use cases, including the use of pointers as function parameters.

44.1 Pointers to Existing Objects

Pointers can point to existing data objects using the address-of operator &. Example:
#include <stdio.h>
int main(void)
{
      char mychar = 'A';
      char *p = &mychar;
      printf("The pointed-to value is: %c\n", *p);
}
Output:
The pointed-to value is: A
This example defines a variable of type char and makes the pointer point at that variable/data object using the &

Get Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.