#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main() {
    //char arr_char[] = {a,b,c}; //not possible, first use in func
    char arr_char[] = {'a', 'b', 'c'}; // Define and init array

    //01.print element
    //write(1, arr_char, 1); //argument: const void *
    write(1, &arr_char, 1); //output: a (only 1st elem)
    write(1, &arr_char, 3); //output: abc

    //02.print adr

    //02-01.
    char *ptr;
    ptr = arr_char; //assign adr of arr to ptr
                    // Buffer to hold the formatted memory address
    char buffer[20]; // Assume mem address can represented in less than 20 char
    sprintf(buffer, "%p", (void*)ptr); // Format mem add as a string

    // Write the formatted memory address to standard output
    write(1, "\n", 1);
    write(1, "1st: ", 5);
    write(1, buffer, strlen(buffer));
    write(1, "\n", 1);

    //02-02
    printf("2nd: %p\n", (void*)ptr); //output: adr stored in ptr
    printf("3rd: %p\n", arr_char); //argument: const void *, printable 

    //03.print size of arr
    printf("%ld", sizeof(arr_char)); //can lead to error, printable, sizeof = ld
    printf("%zu", sizeof(arr_char)); //syntax ok

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: