void main()
{
int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} };
int (*p)[2];
int i,j,*pint;
for(i=0;i<=3;i++)
{
p=&s[i];
pint=p;
printf("\n");
for(j=0;j<=1;j++)
printf("%d",*(pint+j));
}
} while running this program it shows a warning-suspicious
pointer conversion ie pint=p; my que is why should we assign
the value of p to pint again.why cant we use it directly as
*(p+j)..but if i use like tat the o/p is garbage value..
Answer Posted / test
p ia pointer to an array when p is incremented it will increment by the number of elements in the array...
for example
int (*p)[2]; //it is aponiter to an arry of 2 elements so when we do p+1 then it will be incremented by two*(sizeof(int))
so leading to the garbage value at the last loop..
can be properly analyzed by the below program
#include<stdio.h>
main()
{
int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} };
int (*p)[2];
int i,j,*pint;
for(i=0;i<=3;i++)
{
p=&s[i];
//pint=p;
printf("\n");
for(j=0;j<=1;j++)
printf("%p.....%d\n",*(p+j),**(p+j));
}
}
Is This Answer Correct ? | 23 Yes | 2 No |
Post New Answer View All Answers
What are the different types of linkage exist in c?
Is it possible to have a function as a parameter in another function?
What is FIFO?
What is volatile variable in c?
What is difference between class and structure?
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......
How are strings stored in c?
How would you rename a function in C?
Can you write the function prototype, definition and mention the other requirements.
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
Explain can you assign a different address to an array tag?
What is #define?
How many levels of indirection in pointers can you have in a single declaration?
What is function prototype in c with example?
What is scope and lifetime of a variable in c?