+ 1

To find the output of the following array program

There was this program I had to find the output for. I had an array named text[] char text []="Mind@Work!"; After some modifications, it was written, for(int i=0;text[i]!='\0';i++) { //Something was written} cout<<text; My doubt is the last line, shouldn't it be: cout<<text[i] ?? If we directly write array name doesn't it represent the address of the first character/letter/variable of the array?

6th Jul 2018, 10:51 AM
Divyanka Chaudhari
Divyanka Chaudhari - avatar
2 Antworten
+ 2
if i'm not mistaken, doing cout<<text will output the whole thing because it's a string, not something like char text[] = {'M', 'i', 'n', 'd', '@', 'W', 'o', 'r', 'k', '!'};
6th Jul 2018, 11:48 AM
hinanawi
hinanawi - avatar
0
Oh you are quite right!
6th Jul 2018, 12:19 PM
Divyanka Chaudhari
Divyanka Chaudhari - avatar