Structure Pointer in C
Level 4157 keystrokes
Uses arrow operator to access structure members through a pointer.
C code
// Define Rectangle structure1struct Rectangle {2 int width;3 int height;4};5 // Create and initialize a Rectangle6struct Rectangle rect = {10, 5};// Create pointer to the structure7struct Rectangle *ptr = ▭// ptr->width is shorthand for (*ptr).width; 10 * 5 = 508printf("Area: %d\n", ptr->width * ptr->height);Output
Area: 50
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.
;× 6-× 2,× 2"× 2{× 2}× 2*× 2=× 2>× 2:× 1