Answers for "how to return size of array"

C
1

size of array

#include <stdio.h>
#include <stdlib.h>

void printSizeOf(int intArray[]);
void printLength(int intArray[]);

int main(int argc, char* argv[])
{
    int array[] = { 0, 1, 2, 3, 4, 5, 6 };

    printf("sizeof of array: %dn", (int) sizeof(array));
    printSizeOf(array);

    printf("Length of array: %dn", (int)( sizeof(array) / sizeof(array[0]) ));
    printLength(array);
}

void printSizeOf(int intArray[])
{
    printf("sizeof of parameter: %dn", (int) sizeof(intArray));
}

void printLength(int intArray[])
{
    printf("Length of parameter: %dn", (int)( sizeof(intArray) / sizeof(intArray[0]) ));
}
Posted by: Guest on September-23-2021

Code answers related to "how to return size of array"

Code answers related to "C"

Browse Popular Code Answers by Language