arrays - what is the correct string terminator in c -


as know string terminating character in c '\0'.

can use '0' terminating character too? when assign 0 specific index in char array, , use printf, prints upto specific index.

hence, both ways equivalent? null character equal literal 0?

the value can used null terminator numerical value 0.

  • 0 is numerical value 0.
  • '\0' is also way of representing numerical value 0 in code
  • '0' is not numerical value 0 (it's digit zero) , cannot used terminator.

all strings literals implicitly contain null terminator after last visible character. in other cases, may or may not there automatically (depending on how string constructed), have sure in every case null terminator there.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -