Skip to Main Content
Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)
book

Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)

by Zed A. Shaw
July 2015
Intermediate to advanced content levelIntermediate to advanced
380 pages
10h 15m
English
Addison-Wesley Professional
Content preview from Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)

Exercise 15. Pointers, Dreaded Pointers

Pointers are famous mystical creatures in C. I’ll attempt to demystify them by teaching you the vocabulary to deal with them. They actually aren’t that complex, but they’re frequently abused in weird ways that make them hard to use. If you avoid the stupid ways to use pointers, then they’re fairly easy.

To demonstrate pointers in a way that we can talk about them, I’ve written a frivolous program that prints a group of people’s ages in three different ways.

ex15.c

 1   #include <stdio.h>  2  3   int main(int argc, char *argv[])  4   {  5       // create two arrays we care about  6       int ages[] = { 23, 43, 12, 89, 2 };  7       char *names[] = {  8           "Alan", "Frank" ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language

Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language

Slobodan Dmitrović

Publisher Resources

ISBN: 9780133124385Purchase Link