-=> Quoting Kurt Kuzba to Jack Stein <=-
JS> If I have a char array, char string[3] = "123" then say
JS> string[3]=(char)'\0', I then have a string. I'm not sure
JS> why you typed cast the '\0' though, perhaps that was the point?
KK> string[3] is already == '\0' in that case, since it is a
KK> string literal embedded in your code. A char is an integer,
KK> and some compilers will complain if you put an integer into
KK> a char array, hence the cast to (char).
Hello Kurt, looking at the prior fragment under discussion,
char string[3] = "123" has no room for a trailing null. string[0]
contains 1, string[1] contains 2, and string[2] contains 3 while
string[3] is beyond the originally allocated dimensions of the
array.
Regards, Mark Trickett
--- Blue Wave/DOS v2.30
---------------
* Origin: Micom's Maximus CBCS (03) 9752-3949 (3:633/371)
|