473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What would be the result...

Hi friends at present i am not having any compiler so please can any one conform the result of this program
what would be the size of this structure

Expand|Select|Wrap|Line Numbers
  1. struct str 
  2. int data; 
  3. struct str *pstr; 
  4. chap ch; 
  5. int data1; 
  6. };
  7.  
what would be the size of this structure...
Mar 25 '08 #1
5 1134
Studlyami
464 Expert 256MB
In VS 2005 the size is 16, but i believe this is system/compiler dependent so there could be different answers.
Mar 25 '08 #2
JosAH
11,448 Expert 8TB
Hi friends at present i am not having any compiler so please can any one conform the result of this program
what would be the size of this structure

Expand|Select|Wrap|Line Numbers
  1. struct str 
  2. int data; 
  3. struct str *pstr; 
  4. chap ch; 
  5. int data1; 
  6. };
  7.  
what would be the size of this structure...
We don't know because we don't know the size of ints and chars on your system,
nor do we know the size of pointers nor the alignment requirements of your system.

kind regards,

Jos
Mar 25 '08 #3
Banfa
9,065 Expert Mod 8TB
we don't know the size of <snip> chars on your system
In fairness since the size of everything is measured in units of char the size of char will not effect the size of a structure (or anything else) only the min/max values of the integers on the system and I fuess possibly the representation of floats and doubles.
Mar 25 '08 #4
16 is correct for int it would take 4 bytes and for char 4 bytes(due to structure padding) and the pointer 4 bytes so 4+4+4+4=16 ....
Mar 25 '08 #5
Banfa
9,065 Expert Mod 8TB
16 is correct for int it would take 4 bytes and for char 4 bytes(due to structure padding) and the pointer 4 bytes so 4+4+4+4=16 ....
You need to read post 3 much more carefully and understand what it is saying, I have worked/do work on a system where the correct answer is 7 and another where the answer is 8.
Mar 25 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: lawrence | last post by:
If I do something like : $result = mysql_query($query); $dbArray = dbResultIntoKeyArray($result); and this is the function: function dbResultIntoKeyArray($result) {
5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
3
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
4
by: David | last post by:
Hi, Buddy, a newbie's question for you guys, In C++, some functions have a return value type "result", what does this mean, I searched on web, but no hint. thanks a lot David
6
by: WindAndWaves | last post by:
Hi Folks I have inhereted a script that I understand reasonably well, I just do not understand !/^\d+$/.test(el.value) what the hell does that mean? Below is the script (there are really...
1
by: Naga | last post by:
Hello, Thanks for the response Oleg. Now I need to know few answers. How do I get the value of a node using the xpath. I want the value of the MessageID and ResultCode from secondxml. And using...
0
by: Sjaakie Helderhorst | last post by:
Hi all, I'm trying to create a class which handles FTP. Knowing little of classes I'm having some trouble making things work. Also having trouble finding the meaning of some error-codes. The code...
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
6
by: Peter Lee | last post by:
what's the correct behaver about the following code ? ( C++ standard ) I got a very strange result.... class MyClass { public: MyClass(const char* p) { printf("ctor p=%s\n", p);
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...

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.