Simple Pointer Declaration and Use

#include <stdio.h>

int main() {
    // Simple pointer declaration and use
    int number = 42;
    int *ptr = &number;

    printf("Value of number: %d\n", number);
    printf("Address of number: %p\n", (void *)&number);
    printf("Value of pointer (address of number): %p\n", (void *)ptr);
    printf("Value pointed by pointer: %d\n", *ptr);

    return 0;
}
chevron_left
chevron_right

Leave a comment

Your email address will not be published. Required fields are marked *

Comment
Name
Email
Website