foo->bar is equivalent to (*foo).bar, i.e. it gets the member called bar from the struct that foo points to.

Answer from sepp2k on Stack Overflow
🌐
Code.org
studio.code.org › courses › coursec-2025 › units › 1
Unit: Course C (2025) - Code.org
We developed Course C for students in second grade. Students will create programs with sequencing, loops, and events.
🌐
W3Schools
w3schools.com › c › c_arrays.php
C Arrays
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To create an array, define the data type (like int) and specify the name of the array followed by square brackets [].
Discussions

pointers - Arrow operator (->) usage in C - Stack Overflow
I am reading a book called "Teach Yourself C in 21 Days" (I have already learned Java and C# so I am moving at a much faster pace). I was reading the chapter on pointers and the -> (arrow) opera... More on stackoverflow.com
🌐 stackoverflow.com
arrays - How do square brackets work in C? - Stack Overflow
I've just started with C and I'm trying to understand the basics. Plenty of tutorials will tell you things and have you believe it without any real explanation and there are no answers on that I can More on stackoverflow.com
🌐 stackoverflow.com
String Enums in C# — When, Why, and How? : csharp
🌐 r/csharp
Basic String Encryption and Decryption in C# : csharp
🌐 r/csharp
🌐
U.S. Embassy
me.usembassy.gov › home › chargé d’affaires, a.i. michael c. keays
Chargé d’Affaires, a.i. Michael C. Keays - U.S. Embassy in Montenegro
1 day ago - Mr. Keays is a Senior Foreign Service Officer with over 33 years in the U.S. Department of State. He previously worked as a Senior Advisor on the Department’s Policy Planning Staff and in the Department’s Bureau of Cyberspace and Digital Policy. From September 2022 to July 2024, Mr.
🌐
Wikipedia
en.wikipedia.org › wiki › C_data_types
C data types - Wikipedia
3 weeks ago - In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables.
🌐
NSF - National Science Foundation
nsf.gov › news › nsf-doe-vera-c-rubin-observatory-launches-real-time
NSF-DOE Vera C. Rubin Observatory launches real-time discovery machine for monitoring the night sky | NSF - U.S. National Science Foundation
2 days ago - NSF-DOE Rubin Observatory has issued its first scientific alerts, enabling dynamic, real-time observation of the night sky. The alerts are expected to increase to about 7 million per night ... The NSF-DOE Vera C. Rubin Observatory, jointly funded by the U.S. National Science Foundation and the U.S.
🌐
UCSD
cseweb.ucsd.edu › ~ricko › rt_lt.rule.html
C Right-Left Rule (Rick Ord's CSE 30 - UC San Diego)
The "right-left" rule is a completely regular rule for deciphering C declarations. It can also be useful in creating them. First, symbols. Read * as "pointer to" - always on the left side [] as "array of" - always on the right side () as "function returning" - always on the right side as you ...
Find elsewhere
🌐
Spotify
open.spotify.com › track › 6kxxTWhxAwp7vBRiRAAfcf
In C - In C - song and lyrics by Jeroen van Veen | Spotify
January 1, 2008 - Listen to In C - In C on Spotify. Song · Jeroen van Veen · 2008
🌐
W3Schools
w3schools.com › c › c_user_input.php
C User Input
You have already learned that printf() is used to output values in C.
🌐
Embedded Related
embeddedrelated.com › showarticle › 172.php
C Programming Techniques: Function Call Inlining - Fabien Le Mentec
April 29, 2013 - When a function is called from a different compilation units (the usual case), the compiler generates a call instruction. Be it relative, indirect or absolute, the instruction operand (the branch destination address) is resolved by the static linker when merging the compilation units ('.o' files) together.
🌐
Government of Indiana
in.gov › medicaid › members › member-programs › hhw-package-c-medworks-premium
Indiana Medicaid: Members: HHW Package C / MEDWorks Premium
June 16, 2021 - The program covers medical care like doctor visits, prescription medicine, mental health care, dental care, hospitalizations, and surgeries at little or no cost... ... The Healthy Indiana Plan is a health insurance program for adults ages 19 through 64 who are not disabled.
🌐
Legal Information Institute
law.cornell.edu › lii › federal rules of civil procedure
Federal Rules of Civil Procedure | Federal Rules of Civil Procedure | US Law | LII / Legal Information Institute
Judgment; Costs · Rule 55. Default; Default Judgment · Rule 56. Summary Judgment · Rule 57. Declaratory Judgment · Rule 58. Entering Judgment · Rule 59. New Trial; Altering or Amending a Judgment · Rule 60. Relief from a Judgment or Order · Rule 61. Harmless Error · Rule 62. Stay of Proceedings to Enforce a Judgment · Rule 62.1. Indicative Ruling on a Motion for Relief That is Barred by a Pending Appeal
🌐
Mayo Clinic
mayoclinic.org › healthy-lifestyle › nutrition-and-healthy-eating › expert-answers › vitamin-c › faq-20058030
Too much vitamin C: Is it harmful? - Mayo Clinic
February 20, 2025 - Find out how much of this essential nutrient you need each day, and learn what can happen if you get too much.
Top answer
1 of 5
17

I have not explicitly declared int *a as a pointer to an array, but if I allocate it some memory, I can then use a like I had declared it as an array. Is declaring a pointer with square brackets just a shortcut for what I've done below?

Similar, but no. int *a declares a as pointer to int. int b[5] allocates space for 5 ints, declares b as constant pointer to int an array-of-int reference (which can in most cases be treated as a constant pointer to int), and defines b to be the pointer to the allocated space. Thus, int b[5] is doing way more than int *a, which also means int *a is more flexible than int b[5]. For example, you can increment a, but not b.

malloc allocates memory on heap. int b[5], if a global variable, will be in the program's data segment (i.e. it is literally compiled into the executable). If local, it will be allocated on stack. Again, similar, but different.

Are square brackets actually doing some pointer arithmetic?

In declaration, no. When you use pointer variables, yes: x[y] is identical to *(x + y). So a[1] is the same as *(a + 1), which is the same as *(1 + a), which is again the same as 1[a] (but please don't use this last one).

Why is the memory address assigned to a and not *a?

Cheeky answer for a cheeky question: Because you wrote a = ... and not *a = ....

EDIT: John Bode gave a useful pointer (heh): constant pointers and array references are not the same thing, although they are pretty damn similar. For one thing, sizeof(...) will give a different result.

2 of 5
9

Are square brackets actually doing some pointer arithmetic?

Yes. Brackets can be applied to any pointer, not just arrays. They provide a shorthand for pointer arithmetic and pointer dereferencing. Your code is essentially doing this:

Copyint *a = malloc(5 * sizeof(int));

*(a+2) = 4;

printf("%d\n", *(a+0));
printf("%d\n", *(a+2));

Which is actually doing the equivalent of this:

Copyint *a = malloc(5 * sizeof(int));

*((int*)(((unsigned long)a)+(2*sizeof(int)))) = 4;

printf("%d\n", *((int*)(((unsigned long)a)+(0*sizeof(int)))));
printf("%d\n", *((int*)(((unsigned long)a)+(2*sizeof(int)))));
🌐
Embedded Artistry
embeddedartistry.com › home
C - Embedded Artistry
April 2, 2025 - The C standard library is commonly called libc, and occasionally stdlib or cstdlib. For more information and relevant links, see the dedicated glossary entry.
🌐
Lawrence
www2.lawrence.edu › fast › GREGGJ › CMSC480 › intro › C.html
From C++ to C
C does not have classes, so C programs store text as null-terminated arrays of characters and uses pointers to those arrays of characters. Here are some basic examples. To use preset blocks of text in a program you can simply obtain a pointer to text literal.
🌐
W3Schools
w3schools.com › c › c_syntax.php
C Syntax
Line 4: printf() is a function used to output (print) text to the screen. In our example, it prints Hello World!. ... Remember: The compiler ignores extra spaces and new lines, but using multiple lines makes code easier to read.
🌐
W3Schools
w3schools.com › c › c_operators.php
C Operators
int sum1 = 100 + 50; // 150 (100 + 50) int sum2 = sum1 + 250; // 400 (150 + 250) int sum3 = sum2 + sum2; // 800 (400 + 400) Try it Yourself » · C divides the operators into the following groups: