When a string ends '\0' (null) gets added at its end but does it also gets added at the end of an array if not then what ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 3

When a string ends '\0' (null) gets added at its end but does it also gets added at the end of an array if not then what ?

Suppose i declare a string in c++ like this char s[10]="abcdefghi"; 0th position is occupied by 'a' while 8th is occupied by 'i'. 9th position is occupied by '\0'. Is this also the case with an integer array??

5th Apr 2018, 6:30 AM
Rishu Kumar
Rishu Kumar - avatar
1 ответ
+ 1
No. If you declare array of Int in int main() function then it has some trash values. When you declare array before Int main() then it has 0 values not '|0'.
5th Apr 2018, 6:46 AM
Bartosz Pieszko
Bartosz Pieszko - avatar