How does it takes 7th character("X") from IndiaBIX?
7["IndiaBIX"] shall we define like this?
Shamini said:
(Mon, Aug 2, 2010 05:39:42 AM)
printf("%c\n", 7["IndiaBIX"]);
It is printing the 7th character of the string "IndiaBIX".
I-0,
n-1,
d-2,
i-3,
a-4,
B-5,
I-6,
X-7.
Sathya said:
(Mon, Aug 23, 2010 08:29:13 PM)
Thanks Shamini.
Gopi said:
(Thu, Dec 30, 2010 10:30:42 PM)
Good. Thank you.
Narendra said:
(Thu, Jan 20, 2011 11:27:49 PM)
I think when we write like that then compiler will skip first 6 letters &then print remaining.
Umu said:
(Sun, Feb 13, 2011 01:34:34 PM)
@narender no you are wrong.
@samini good thnx. :).
Manoj said:
(Wed, Feb 23, 2011 05:12:44 AM)
Hey program is good, because whenever complier can't define any data type or user define %c means char or you can modify this program or define %f,
%d then you will get satisfied answer.
Ya correct guys, if it is printf("%d",7[indiabiA]);
means it will print the integer values as A=65
Venky said:
(Sun, Aug 7, 2011 10:44:15 PM)
Actually: num[i]<=>*(num+i)<=>*(i+num)<=>i[num]
So 7 is index and indiabix is string. Thus X of indiabix.
Raghu said:
(Sat, Aug 13, 2011 02:51:02 PM)
It is just trick of mathematics. a[3] = 3[a] --> they are commutative both are expanded by compiler as *(a+3) and *(3+a) respectively. Even you can assign a variable to 3[a] = "X" which is same as a[3]="X".
Sanketrjain said:
(Sat, Aug 27, 2011 07:19:16 PM)
Thanks raghu and shamini.
Lavanya said:
(Mon, Sep 19, 2011 08:29:36 PM)
Thanks venky, raghu and shamini.
Sindhu said:
(Tue, Nov 29, 2011 12:59:06 PM)
Thanks wikiok.
Mesv said:
(Tue, May 29, 2012 08:13:42 PM)
No need to think more.
7["givenstring"] means it take 7th char of that string.
And string starts from 0 index.
Here "r".
Devanshmody said:
(Sun, Jul 1, 2012 11:32:33 AM)
They have used %c so it will take one character and 7 is given and x is at 7 position.
Varun said:
(Wed, Aug 22, 2012 08:09:07 PM)
No it will not print all the characters after 6 characters. if we keep 7+"IndiaBIX" then we will get output as you told..@narendra
Harsha said:
(Thu, Aug 23, 2012 01:21:43 AM)
It will print all characters after x in the string since there is only one character left it prints x
Prasad said:
(Wed, Sep 26, 2012 12:41:45 PM)
Suppose take an example...
int a[3]={10,20,30};
printf("\n%d%d%d",0[a],1[a],2[a]);
same way as a[0] a[2]....
in the above example 7 is treated as index.