0

Why this code is printing whole string?. When we write string or int in place of char datatype then, it gives us address why?

https://code.sololearn.com/cGS33D0QTOyA/?ref=app

21st Apr 2022, 5:17 AM
Muhammad Talha Atif
Muhammad Talha Atif - avatar
3 Réponses
+ 2
Only char array get treated special. All other arrays are addresses. structures display address too. The char arrays are special because they are the default string type.
21st Apr 2022, 7:12 AM
John Wells
John Wells - avatar
+ 1
string is a class which does not get handled by cin or cout, unless you provide a function to do so. C++ does not provide one so the default action is display the instance's address. Arrays beyond char also do not know hold to display them.
21st Apr 2022, 5:45 AM
John Wells
John Wells - avatar
0
So what about integer arrays?.They also display address
21st Apr 2022, 6:19 AM
Muhammad Talha Atif
Muhammad Talha Atif - avatar