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


Please Help Members By Posting Answers For Below Questions

What is a pointer value and address in c?

630


How can I manipulate strings of multibyte characters?

631


write an algorithm to display a square matrix.

2218


What is the modulus operator?

730


How can I determine whether a machines byte order is big-endian or little-endian?

615






PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

1703


What are the benefits of organizational structure?

567


what are non standard function in c

1431


write a program to create a sparse matrix using dynamic memory allocation.

4370


What is const and volatile in c?

561


What is the difference between break and continue?

602


What is sizeof int in c?

594


What does c in a circle mean?

578


What are the advantages of using Unions?

642


What are the advantages of using macro in c language?

585