The UNIX and Linux Forums
Forum Home
Linux and Unix Man Pages
Search Forums
Search Community Posts
Today's Posts
Quick Links
Man Pages
RedHat Commands
OpenSolaris Commands
Linux Commands
SunOS Commands
FreeBSD Commands
All UNIX Man Pages
All Linux Man Pages
Full Man Repository
Login or Register to Ask a Question and Join Our Community
Search Forums
Show Threads .
Show Posts
Tag Search
Advanced Search
Quick Links
Contact Us
Forum Rules
Today's Posts
FAQ
Pictures & Albums
All Albums
Miscellaneous
What is My IP
Whois
Mark Forums Read
Programming
arraySize
Tags
programming
Login to Discuss or Reply to this Discussion in Our Community
Thread Tools
Search this Thread
Top Forums
Programming
arraySize
#
1
09-19-2007
arunviswanath
Registered User
8,
0
Join Date: Jul 2006
Last Activity: 21 January 2008, 3:10 AM EST
Posts: 8
Thanks Given: 0
Thanked 0 Times in 0 Posts
arraySize
Hi ,
I like to find the size of an array in the function which takes an array as a parameter .
eg:
void fun(int a[])
{
// Size of an array `a` to be calculated here
}
int main()
{
int a[10];
fun(a);
}
arunviswanath
View Public Profile for arunviswanath
Find all posts by arunviswanath
#
2
09-19-2007
porter
Registered User
2,965,
5
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks Given: 0
Thanked 5 Times in 5 Posts
Answer is - you can't.
As all you get in fun is a pointer.
however, you can with a macro
#define fun(x) (sizeof(x)/sizeof(x[0]))
porter
View Public Profile for porter
Find all posts by porter
Login or Register to Ask a Question
Previous Thread
|
Next Thread
Login or Register to Ask a Question
Member Badges and Information Modal
×