Using C strings a buffer is need to store usernames of up to

Using C strings a buffer is need to store usernames of up to 80 characters that will be typed in by the user via the keyboard. The following declaration will suffice char buffer[80]; True False

Solution

The answer will be false if we were looking so strict on the rules.

Reason:

C or C++ stores strings starting from an index of 0 till the specified index and the last position is reserved for a NULL characted also mentioned as \'\\0\' which means that the string gets terminated. So, it is important to give 1 size more than the number of characters you would like to have which means, for a buffer upto 80 characters, we need:

char buffer[81] which is one location more than the specified variable.

 Using C strings a buffer is need to store usernames of up to 80 characters that will be typed in by the user via the keyboard. The following declaration will s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site