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



void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pin..

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

More C Interview Questions

Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

0 Answers   Huawei,


how is the examination pattern?

0 Answers   Wipro,


How to add two numbers without using semicolon n c????

3 Answers  


Is boolean a datatype in c?

0 Answers  


how many header file is in C language ?

44 Answers   College School Exams Tests, CTS, IBM, IMS, Infosys, ME, Sign Solutions, Wipro, XVT,






What is the purpose of the code, and is there any problem with it? unsigned int f( unsigned n ) { return –n & 7; }

1 Answers   Google,


without using arithmatic operator convert an intger variable x into x+1

3 Answers  


What are the different types of endless loops?

0 Answers  


What are the various topologies? Which one is the most secure?

2 Answers  


Why cant I open a file by its explicit path?

0 Answers  


write an algorithm and c program to add two 2x2 matrics

2 Answers  


I didn't count the ducks that I saw in line, but I do remember that one duck was in front of two ducks, another duck behind two ducks. How many ducks did I see?

2 Answers  


Categories