Is there any way of writing VB ubound(returns the index of the last element in the array) to c
instead of using sizeof operator
int arr[20];
printf("%d",sizeof array/sizeof(int));
how to write using queue?
Is there any way of writing VB ubound(returns the index of the last element in the array) to c
instead of using sizeof operator
int arr[20];
printf("%d",sizeof array/sizeof(int));
how to write using queue?
As in you're implementing a queue? Then keep track of the start and end of the queue, or use a linked list where you track the tail.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
You really should consider spending less time trying to convert some VB code and more time learning the C language.
Assuming you're working with an array, the technique sizeof(array)/sizeof(*array) is the usual technique.
If you're working with a pointer rather than an array (and that includes passing an array to a function) there is no way in C. When an array name is converted to a pointer, that pointer is associated with no information about the size of the original array. There is therefore no way to extract such information.
As laserlight suggested, if you're implementing a queue, then your implementation of the queue needs to do bookkeeping to keep track of the required length.