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 identifiers and keywords in c?
What does dm mean sexually?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
Explain is it better to bitshift a value than to multiply by 2?
Is javascript written in c?
What is const volatile variable in c?
What is an auto keyword in c?
Can you return null in c?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
Is that possible to store 32768 in an int data type variable?
What is the use of bitwise operator?
What is array in C
What is struct node in c?
How can I swap two values without using a temporary?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference