Program Console Vignaankosh.com
Execution Panel
Console is empty.
Size of structure and padding concept is an interactive C dry run visualizer from the Structures programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
struct Example1 {
char c; // 1 byte
int i; // 4 bytes
}; // Typically 8 bytes (1 + 3 padding + 4)
struct Example2 {
int i; // 4 bytes
char c; // 1 byte
}; // Typically 8 bytes (4 + 1 + 3 padding)
struct Example3 {
char c1; // 1 byte
char c2; // 1 byte
int i; // 4 bytes
}; // Typically 8 bytes (2 + 2 padding + 4)
struct Example4 {
char c; // 1 byte
double d; // 8 bytes
}; // Typically 16 bytes (1 + 7 padding + 8)
int main() {
printf("Size of Example1: %lu bytes\n", sizeof(struct Example1));
printf("Size of Example2: %lu bytes\n", sizeof(struct Example2));
printf("Size of Example3: %lu bytes\n", sizeof(struct Example3));
printf("Size of Example4: %lu bytes\n", sizeof(struct Example4));
printf("\n--- Address demonstration ---\n");
struct Example1 ex1;
printf("Address of ex1.c: %p\n", (void*)&ex1.c);
printf("Address of ex1.i: %p\n", (void*)&ex1.i);
printf("Difference: %lu bytes\n", (char*)&ex1.i - (char*)&ex1.c);
return 0;
}