Struct Definition in C
Level 4147 keystrokes
Defines a struct with x and y coordinates, creates an instance, and modifies it.
C code
// Define a struct named Point with two integer members1struct Point { // x coordinate member2 int x; // y coordinate member3 int y;4};5 // Create and initialize a Point instance6struct Point p1 = {10, 20};// Access struct members using dot notation7printf("x: %d, y: %d\n", p1.x, p1.y);// Modify the x member8p1.x = 30;// Print updated values9printf("x: %d, y: %d\n", p1.x, p1.y);Output
x: 10, y: 20 x: 30, y: 20
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
,× 7;× 7.× 5:× 4"× 4%× 4(× 2)× 2{× 2}× 2