When you do c[1].courseno it will print the 'c[1]' array 1st variable ie 103 then (*(c+2)).coursename it will go into c[2] array's coursename contents.
Sivaram said:
(Sun, Jan 16, 2011 04:40:09 AM)
Thanks praveen.
Jitu Rahangdale said:
(Fri, Feb 18, 2011 10:48:29 AM)
Ok, pravin said is right. I agree with him.
Iram said:
(Fri, Mar 18, 2011 06:53:35 AM)
Anyone can explain in detail.
Prits said:
(Thu, Jun 16, 2011 05:29:58 AM)
What is use of pointer here? any special use? will anyone explain that please.
Thanks.
Apurva Nigam said:
(Tue, Jun 28, 2011 06:38:37 AM)
The c[1].courseno points to 103 ( hope you agreed).
In (*(c+2)).coursename , *(c+2) is same as writing c[2] that is c[2] or *(c+2) points to {104, "DotNet"}
Therefore (*(c+2)).coursename or u can say c[2].coursename will give DotNet.
Take care :)
Sravanthi Emmadi said:
(Thu, Aug 4, 2011 01:21:12 PM)
Thank you Apurva.
Ramdas said:
(Wed, Aug 24, 2011 10:32:48 AM)
When we refer c[1], it returns 103.
And when we are using (* (c+2) ). Coursename) it refers to c[2]. Coursename because c itself points to starting address of array c. C+2 is refers to c[2]address. For getting the value in that location used * deference operator.
Safi said:
(Sat, Dec 31, 2011 11:03:43 AM)
The struct is a user defined data type,means defines by user for avoid multiple declaration in the program body.this data type is accessed by a Dot "." operator. Fine......
Here struct for "course" variable. Now
printf("%d", c[1].courseno);
will return courseno stored at 2nd array location of c,ie c[1] bcz by default array initiates with index 0 and it is 1st location of that array...while return type in printf function is integer.....
and
printf("%d", c[1].courseno);
ans= 103
we can write c[2] as similar to (*(c+2)) and vise versa.
hence using above funda
printf("%s\n", (*(c+2)).coursename);
return type in printf function is string, therefore
it gives answer
DotNet
I thought you cleared.
Satyaprakash said:
(Tue, Jan 10, 2012 07:23:58 PM)