Reputation: 2550
What is the meaning of (char)0
.
For example what does this mean?
array[1] = (char)0;
Upvotes: 2
Views: 7921
Reputation: 28762
You are casting an int (integer) (0
) to a character (char).
Casting means you are changing the type.
Upvotes: 0
Reputation: 36986
It's a C-style cast. That is, it converts 0
(which is a literal of type int
) to char
(the \0
character). That cast could have been avoided entirely by simply using the '\0'
literal.
Upvotes: 6