0
what is char text[20];? and why index 20 is taken in the array
5 odpowiedzi
+ 6
Here you defined char array text which type is character type . And you mentioned array size 20 it means your array can store 20 characters.
For example
char text[5]= "Helloworld";
Here i gave array size 5 and my total chars are 10 so it will give you errors so it represent your size .
If u dont want to mention size the u can write like this
char text[ ]= "Helloworld";
Here in bracket don't mention size your array will take size automatically and it will run without error.
+ 3
LastSecond959 yes you saying right if you have doubts you can print length your doubt will be clear
0
when defining that variable, you have to specify size of character array. In your case it is 20.
0
how 20 can you explain to me, please
0
Supporting ♨️TEJAS MK-82♨️ 's answer,
Technically yes, you declared an array of chars of size 20, it has the index of [0] to [19] but I suggest you assign a value to it for maximum of 19 characters (until index [18], because index [19] will be used as a string terminator, the '\0' character). The point is, it is correct to say it CAN store 20 characters, but you SHOULD store 19.