C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Yes / No Questions (Q.No. 5)
5.
Are the following declarations same?
char far *far *scr;
char far far** scr;
Discussion:
6 comments Page 1 of 1.
Pruthvi said:
1 decade ago
Can any one explain me what does it actually mean by the above statements. Please.
Rahul said:
1 decade ago
The first statement is declaring two far pointers. But I didn't get the next declaration. Can any one explain me the next one?
Swayam said:
1 decade ago
Can anyone explain this with examples so that I could understand it more cleary?
Arun Prasad said:
1 decade ago
char far *far *scr; -> It means scr is a far pointer to a far pointer to a char, or u can understand it as scr contains a far address of a far pointer to a char.
(far *scr) means scr is a far pointer.
(far *(far *scr)) means scr is a far pointer to a far pointer.
(char (far *(far *scr))) means scr is a far pointer to a far pointer to a char.
For better understanding assume it as,
scr(far type)-> *scr(far type)-> **scr(char type)
Take a example. Suppose address of **scr(char type) is 100, *scr(far type) is 200, scr(far type) is 300.
Now scr(far type) contains 200(address of *scr(far type)) and *scr(far type) contains 100(address of **scr(char type).
In 2nd Case: char far far** scr;
In this case scr(far type) contains 100(address of **scr(char type)) because you can see that (far **scr).
So we can say that the two declarations are different.
(far *scr) means scr is a far pointer.
(far *(far *scr)) means scr is a far pointer to a far pointer.
(char (far *(far *scr))) means scr is a far pointer to a far pointer to a char.
For better understanding assume it as,
scr(far type)-> *scr(far type)-> **scr(char type)
Take a example. Suppose address of **scr(char type) is 100, *scr(far type) is 200, scr(far type) is 300.
Now scr(far type) contains 200(address of *scr(far type)) and *scr(far type) contains 100(address of **scr(char type).
In 2nd Case: char far far** scr;
In this case scr(far type) contains 100(address of **scr(char type)) because you can see that (far **scr).
So we can say that the two declarations are different.
Mangusta said:
1 decade ago
How can scr contain address of **scr ? scr is supposed to contain address of *scr, as far as I know at least : ).
Seema said:
1 decade ago
Can you explain me both pointers?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers