954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

sizeof

if would like to print the size of data type entered by user. how can i do so (without using case and if)
is it possible to store the data type in a string and print the size of data type in that string???

jatinkhandelwal
Newbie Poster
4 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

A user doesn't enter a data type. They enter data that is put into a variable which is defined by a data type at compile time. So at compile time the data type size is already defined and can be output using sizeof(<em>datatype/variable</em>) .

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 
A user doesn't enter a data type. They enter data that is put into a variable which is defined by a data type at compile time. So at compile time the data type size is already defined and can be output using sizeof(<em>datatype/variable</em>) .


i want something like this
i want to search a file for various data types and print the sizes of them acordingly

jatinkhandelwal
Newbie Poster
4 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

Then you need to create a mapping from data type to size and store it in a file. Once you've done that just search that file for the data type you are interested in.
Although, as WaltP has already mentioned, the size of a type is available at compile time using sizeof .

L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124
 
i want something like this i want to search a file for various data types and print the sizes of them acordingly

Post some examples of what will be in the file so that we don't have go guess that you want.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: