Character Array in C

Level 255 keystrokes

Stores the string "Hello" in a char array, then prints the whole string with %s and its first character with %c, giving "Hello, H".

C code

// Creates a char array of 6 elements: the 5 letters of "Hello" plus a terminating '\0'
1char name[] = "Hello";
// %s prints characters up to the '\0'; %c prints only name[0], the first letter 'H'
2printf("%s, %c", name, name[0]);

Output

Hello, H
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • "× 4
  • ,× 3
  • ;× 2
  • [× 2
  • ]× 2
  • %× 2
  • (× 1
  • )× 1
  • =× 1

More C examples at level 2

← C typing practice