This wont work in case of char pointers since you cannot change contents of read only block...
Type: Posts; User: Saurabh Mehta
This wont work in case of char pointers since you cannot change contents of read only block...
I have the following code.According to this the values of pointers p[0] and p[1] remains unchanged since the swap is made to local variables in swap function.Now my doubt is how can I swap the...
#include<stdio.h>
int i=5;
main()
{
int i=6;
{
int i=7;
printf("%d",i);
@jimblumberg Thank you for your answer..but my question is that why the declaration is allowed inside switch block and not allowed inside case statement...although incase of inside switch you can...
#include<stdio.h>
main()
{ switch (i)
{ case 1:
int a = 3;
break;
case 2:printf("hello"); break; } }
@grumpy thank you for your valuable contribution..
I think that its because of padding that extra bits are added..Because if i do sizeof(struct ss) it gives 16 and not 12...Please contribute if I am wrong?
Yeah that i know..in my case it means wirting to c and d means overiding the values of a and b...But why does that 32767 come??
main()
{
union u
{
struct s{int a;int b}n;
struct ss{int c;long d}ni;
}uu;
uu.ni.c=1;
main()
{
union u
{
struct s{int a;int b}n;
struct ss{int c;long d}ni;
}uu;
uu.ni.c=1;
Thank you...you rockkkkk!!
I came across the foll code in c99 standard:
Otherwise, if the type of the operand with signed integer type can represent
all of the values of the type of the operand with unsigned integer type,...
Thank you it was great explaination ...I have a last doubt that does compiler decides order of evalauation or is it always left to right??
@jimblumberg thank you but even if I remove paranthesis then also the result is the same i.e j is considered first and then the other parts of the expression..As far as I know precedence means That...
Thank you for your explaination but as per the foll link it says && has higher precedence than ||..So why does in my case || gets evaluated first C Language Operator Precedence Chart
came across the foll code:
#include<stdio.h>
main()
{
int i=4,j=7;
Then why doesnt it do the same thing when only 1 bit is increased I mean why on increasing size with just one bit it straight away increases the total size by 4 bytes??
But when I replace sizeof c with 2 bits then it gives 8 as output ..Can someone please explain how is this possible???
the foll code when run on gcc compiler gave 12 as output
struct aa{char a:3;int b:30;char c:3;};
printf("%d",sizeof(struct aa));
but since sizeof int is 4 and char is 1 then why does...
Thank you it was a really great explaination!!!!
The foll code
static int a;
extern int a;
gave no error on gcc
But the foll gave error :
@phantomotap thank you for your answer but in my previous question when i run the code by removing static from the global variable it gave no errors why is that so??
I didnt mention 'extern' in my previous comment:) No problems but now I have another doubt the following code gave error as "non static declaration of 'a' follows static declaration"
static int...
Then why does removing static gives no error although it is defined after main()..??
Thank you but I think static variables have internal linkage that is available to same file and not to outside files..