- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Alternative for sizeof operator
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 08:36 PM
тАО09-03-2003 08:36 PM
Is there any alternative to find the size of
data type like int, char apart from sizeof() operator.
Thanks,
Poornima.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 09:04 PM
тАО09-03-2003 09:04 PM
Re: Alternative for sizeof operator
What (programing) language are you talking about?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 09:12 PM
тАО09-03-2003 09:12 PM
Re: Alternative for sizeof operator
I am talking about C programming language.
Thanks,
Poornima
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2003 11:16 PM
тАО09-03-2003 11:16 PM
Re: Alternative for sizeof operator
No there is not alternative to sizeof() operator in standard ANSI C.
Sizeof() is a compiletime operator can be applied to type too ,i.e. sizeof(int); runtime not call any function so sizeof() is very quick.
Why do you will not use sizeof() operator?
Antoniov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2003 01:15 AM
тАО09-04-2003 01:15 AM
Re: Alternative for sizeof operator
Actually, this is a tricky question asked
by one of my friends who is proficient is C language.
Thanks,
Poornima.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2003 04:40 AM
тАО09-04-2003 04:40 AM
Solutionif it's only a tricly question, you can use other then sizeof as follow:
#include
#define mysize sizeof
main ()
{
unsigned short size_of;
long iMyVar, *piMyVar;
piMyVar = iMyVar;
size_of = ((unsigned long) (piMyVar + 1))
- ((unsigned long) (piMyVar));
printf("%d %d %d",mysize(iMyVar), size_of, sizeof(iMyVar));
}
Above program run correctly (you can try).
1.st is a macro that redefines a sizeof operator.
In second statetemnt (size_of = ...), program evaluate address of a variable and next location; every address is casted into long and different is located in size_of variable.
Look that without unsigned long casting, different it equal to 1!!
H.T.H.
Antoniov