1) you cannot change the const variable .
2) generally sizeof behaviour in case of structure is just undefined. Either
it follows the summation of size of members or it uses padding concept ie in
your example 4 byte each for character(1 byte for char rest of the 3 bytes
is padded up) and 4 byte for integer .This is more efficient

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.
>

-- 
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