c m y k
127www.
openITis.
com | LINUX For YoU | FebrUarY 2008
In the following programs, assume that necessary header
files are included.
Q1.
Will this program result in an assertion failure?
int main() {
assert(sizeof(void *) == sizeof(int *));...
More
c m y k
127www.
openITis.
com | LINUX For YoU | FebrUarY 2008
In the following programs, assume that necessary header
files are included.
Q1.
Will this program result in an assertion failure?
int main() {
assert(sizeof(void *) == sizeof(int *));
assert(sizeof(int *) == sizeof(int **));
}
Q2.
What will this program print?
int main() {
int iarr[10];
int *i = &iarr[2], *j = &iarr[5];
int *k = i + j;
int diff = j – i;
printf(“%d”, diff);
}
Q3.
Will this program work?
int main() {
int i = “C is often unpredictable!”;
printf(i);
}
Q4.
What does the following program print?
int main() {
char string[10];
printf(strncpy(string ,”Joy of C”,3)[3] = ‘\0’);
}
Q5.
What does this following program print?
int main() {
// assume that address of i is 0x1234ABCD
int i = 10;
int * ip = &i;
int **ipp = &&i;
printf(“%x, %x, %x”, &i, ip, *ip);
}
Well, they don’t seem too difficult, do they? It is too soon
S.
G.
GaneSh
Pointers are the forte of C, are the most difficult to master, and programming with
Less