Void pointer usage Dry Run in C

Void pointer usage is an interactive C dry run visualizer from the Pointersintro 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.

Void pointer usage Program Code

#include <stdio.h>
int main() {
    int i = 42;
    float f = 3.14;
    char c = 'A';
    
    void *vptr;  // Generic pointer
    
    vptr = &i;
    printf("Integer: %d\n", *(int*)vptr);
    
    vptr = &f;
    printf("Float: %.2f\n", *(float*)vptr);
    
    vptr = &c;
    printf("Char: %c\n", *(char*)vptr);
    
    // Size of void pointer
    printf("\nSize of void pointer: %lu bytes\n", sizeof(vptr));
    
    // Note: Can't dereference void pointer without casting
    // printf("%d", *vptr);  // ERROR! Can't dereference void*
    
    return 0;
}

View the complete Pointersintro programs page.

Program Console Void pointer usage Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.