1. Yes, you cannot modify a const variable. This itself means that it is
read-only.

2.Google structure padding. It is done to make sure that variables start in
memory at addresses that are a multiple of their size. This is more
efficient at hardware level.
 'char' (1 byte) variables can be byte aligned and appear at any byte
boundary.
 'int' (4 byte) variables must be 4 byte aligned ( they can only appear at
byte boundarys that are a multiple of 4 bytes). So, here
 char b --- At any available byte
 int c ------ 3 bytes from b.
So, a total of 1+3+4 = 8 bytes.


On Sun, Jul 17, 2011 at 11:38 PM, Abhi <abhi123khat...@gmail.com> wrote:

> 1.When I declare a variable as const then any subsequent assignment of it
> gives an error "assignment of read only variable". Is a const variable
> treated as a read only variable?
>
>
> 2.
>
> #include<stdio.h>
> struct s1 {
>       char a;
>      };
>
> char s2 {
>      char b;
>      int c;
>        };
>
> printf("%d",sizeof(struct s1));  // output : 1
> printf("%d",sizeof(struct s2));  // output : 8
>
> please explain..
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/nOK4AkuAgW8J.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Best Regards,
Harshal Choudhary
7th Semester, CSE Dept.
NIT Surathkal, India.
"The road to knowledge runs through the land of confusion."

Mobile: +91 9844667142
Email : hc4...@gmail.com
<http://www.facebook.com/profile.php?id=1518764305>
<https://twitter.com/#!/harshal4342>
  <http://www.linkedin.com/pub/harshal-choudhary/17/731/291>
<http://kkoolharshal.blogspot.com>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to