user775093
user775093

Reputation: 749

Understanding char array initialization behavior

I am writing a program in which I am initializing a char array as follows

char array[28] = "\19TTTxxxxxxx Protocol\x00\x00\x00\x00\x00\x00\x00\x00";

But the above statement gives a warning that "initializer string too long ". But when I change it to \20, it doesn't give the warning.

Can someone explain whats going on here?

Upvotes: 0

Views: 80

Answers (1)

user2404501
user2404501

Reputation:

"\20" is a single character with octal value 020. "\19" is two characters, the first having octal value 01 and the second being '9'.

9 is not an octal digit.

Upvotes: 2

Related Questions