Total bytes of an array

Wednesday, October 15, 2014
/* 1202.c: Total bytes of an array */
#include <stdio.h>

main()
{
    int total_byte;
    int list_int[10];

    total_byte = sizeof (int) * 10;
    printf( "The size of int is %d-byte long.\n", sizeof (int));
    printf( "The array of 10 ints has total %d bytes.\n", total_byte);
    printf( "The address of the first element: 0x%x\n", &list_int[0]);
    /* also first element address can be obtained by */
    printf( "The address of the first element: 0x%x\n", &list_int);
    printf( "The address of the last element: 0x%x\n", &list_int[9]);
    return 0;
}

Copyright @ 2015 Tron!

Labels

Blog Archive