CKTIS / C
Member access: the . operator
The . operator selects a named member of a struct or union object. For a pointer, use -> instead.
Version: C23; repository compiler flag, production runtime not attested
Syntax
object.memberobject.member selects a struct or union member; the name must belong to that type. For a pointer p, use p->member or (*p).member.
The result is an lvalue if the left operand is one. Writing requires a modifiable lvalue; qualifiers such as const carry through to the member. Accessing a member of an atomic object has undefined behavior.
In the example, p.x = 7 changes only x; p.y remains 3. The dot in the designated initializer .x = 7 is not member access.
Examples
#include <stdio.h>
struct Point {
int x;
int y;
};
int main(void)
{
struct Point p = {2, 3};
p.x = 7;
printf("%d %d\n", p.x, p.y);
return 0;
}
Result
7 3
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.