473,770 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i emulate sizeof()

Hello all,
How can i emulate sizeof()
only for integers?
Jun 27 '08
14 1721
In article <g0*********@re gistered.motzar ella.org>,
Eligiusz Narutowicz <el************ *@hotmail.comwr ote:
....
>It's not lunacy, if a woman tells you she'll sleep with you if can write
a program that calculates the size of an object without using the
built-in sizeof operator. It becomes a very worthwhile endeavor.

That's the problem with a lot of the answers given here. They lack
context.

I think the lack of context is more the problems of the question in this
case.
I think (against the tide, I understand) that you should assume that a
poster has a reason for posting (as he does).

He should not have to justify that position beyond that which the fact
that he has posted has already done so.

Jun 27 '08 #11
In article <g0**********@n ews.xmission.co m>,
Kenny McCormack <ga*****@xmissi on.xmission.com wrote:
>I think (against the tide, I understand) that you should assume that a
poster has a reason for posting (as he does).
Yes, but for most of these sizeof() questions the context seems most
likely to be "I can't do the questions on my C test".

-- Richard
--
:wq
Jun 27 '08 #12
In article <g0***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>In article <g0**********@n ews.xmission.co m>,
Kenny McCormack <ga*****@xmissi on.xmission.com wrote:
>>I think (against the tide, I understand) that you should assume that a
poster has a reason for posting (as he does).

Yes, but for most of these sizeof() questions the context seems most
likely to be "I can't do the questions on my C test".

-- Richard
--
:wq
"Passing the class" is probably an even more important - and more deserving
reason - than "I wanna get laid".

Jun 27 '08 #13
On Apr 30, 8:26*pm, Kenneth Brody <kenbr...@spamc op.netwrote:
Eugeny Myunster wrote:
Hello all,
* * * * How can i emulate sizeof()
* * * * only for integers?

I'd really love to know which instructors keep giving this assignment.

Why do you want to "emulate sizeof", when sizeof exists just for this
purpose?

How about:

* * #define MySizeof(x) sizeof(x)

Now you can "emulate sizeof" by using "MySizeof(int)" , for example.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody * * * *|www.hvcompute r.com| #include * * * * * * *|
| kenbrody/at\spamcop.net |www.fptech.com* * | * *<std_disclaime r.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsA SpamT...@gmail. com>
I think it is a punishment for missing some homework or something. I
totally agree with the Macro approach. Ask your instructor, What is
the point of this assignment?, will I ever work on a project and try
to emulate this?
Jun 27 '08 #14
Kenny McCormack wrote:
>
In article <g0***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
In article <g0**********@n ews.xmission.co m>,
Kenny McCormack <ga*****@xmissi on.xmission.com wrote:
>I think (against the tide, I understand) that you should assume that a
poster has a reason for posting (as he does).
Yes, but for most of these sizeof() questions the context seems most
likely to be "I can't do the questions on my C test".

"Passing the class" is probably an even more important - and more deserving
reason - than "I wanna get laid".
Quandry:

Professor says "get the size of an object without using sizeof".

SO says "don't".

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>
Jun 27 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7544
by: Bruce A. Julseth | last post by:
How do I emulate the web page "Close" Button, i. e. the "X" in the upper right hand corner of each web page? Thank you.... Bruce
2
4184
by: Bart Nessux | last post by:
This probaly isn't possible with Python, but I thought I'd ask. I want to emulate a key press programatically. I want the computer (G5 running Mac OSX 10.3) to think that the user has pressed the space bar on the keyboard. Any module in Python that makes this easy? If not, I'll do something in C.
1
1865
by: Bob Van Der Ploeg | last post by:
I need a DB design to emulate a operating system so I can add folders (Categories) with unlimited folders (Sub categories) in side folders Any suggestions? Bob
2
1608
by: bulk88 | last post by:
How can I emulate DOM level 1 removeChild in IE 4? I already figured out to emulate getElementById by doing this if((!document.getElementById) && document.all) {document.getElementById = function(id){return document.all;}; } Is there something similar for removeChild?
61
16298
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step simulation - display registers contents I tried to search con google with no success.
3
2134
by: mario.rossi | last post by:
Hello! I would like to write a pointer to type template that behaves exactly and completely like normal pointers, which I will use as starting point for other kinds of pointers that hold extra data (for example, one of my aims is to have 64bit pointers on a 32bit machine, and ignore the highmost 32bits of the address, while still keeping it in structures and function parameters, so I can start to migrate my 32bit OS to 64bit, although I...
7
1677
by: C a r l o s A n t o n i o | last post by:
Hello, I have to submit a file via HyperTerminal using my PC's internal modem on a daily basis. Does anybodoy know how to accomplish this in VS2005? Any language is good, VB preferred. Thanks. Regards,
11
3970
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject is instance of MyEntity class. There is no MyProperty property in MyObject at design time.
0
2013
by: Sin Jeong-hun | last post by:
The term 'system-wide' just means that click is dealt in whole-screen wide level. Just like the real mouse pointer. What I'd like to do is to emulate mouse move and click. For example, the command is something like "Move the mouse to the 300,400 of the screen and click." I know that I can send mouse clcik message to a specific window using WinAPI. But can't I just emulate 300,400 click of the real screen? I thought that I might need to...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.