Showing posts with label size. Show all posts
Showing posts with label size. Show all posts

Wednesday, September 28, 2011

Transferring array between functions using pointers, getting the size of array without using strlen


#include<stdio.h>
#include<string.h>
#define elements_count (sizeof(arr)/sizeof(arr[0]))

int compute_size(int arr[])
{
    return elements_count;
}
main()
{
    int list[]={11,12,13,14,15,16};
    int x,size;
    size=compute_size(list);
    for(x=0;x<size;x++)
    printf("%d",list[x]);
}