Correct a plant label
Before you start this advanced track
Arrays and functions, plus the basics of memory addresses, pointers, and byte sizes.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
A character array initialized from a string contains editable characters followed by a terminating zero byte. Array indexes begin at zero. Assigning a single-quoted character to one array element replaces just that character. The %s format prints the characters through the end of the string, stopping before its zero terminator.
#include <stdio.h>int main(void) { char label[] = "moss"; label[0] = 'M'; printf("%s\n", label); return 0;}Each example is a complete C11 console program. Compile as C, not C++. Arrays are local objects with the sizes shown; no input or external files are needed.
Track the values line by line. Predict the result before running this example in your own editor.