STRINGS (ARRAY OF CHARACTERS)

METHOD 1:

char protagonist[10] = {'B', 'i', 'l', 'b', 'o', '\0'};

 * whenever you use the name protagonist it’ll be interpreted as a pointer to the 
   first element
    - char protagonist[10] = "Frodo"; will point to "protagonist[0]" which is the
      character "F"
 * NTS: the CHAR data type is the distinguishing factor to this strings!
 * the \0 is an empty character or nul
    - null-terminated character arrays are used to represent strings. The \0 character 
      signifies the end of the string, allowing functions like strlen() and printf() to 
      know where the string ends
    - When users enter text from the keyboard and press the "Enter" key, the system 
      typically sends a newline character (\n) to the input stream. However, when 
      storing that input as a c style string, the newline character is often replaced 
      or followed by the null terminator \0. The C standard library functions like 
      fgets() or scanf() with the %s format specifier, when used to read keyboard input,
      will add the null terminator \0 to the end of the string. Therefore, the enter key
      indirectly causes the end of the string, by triggering functions that append the 
      null terminator. It is not the enter key itself that is stored as the null 
      terminator, but rather that the pressing of enter causes the program to know 
      to terminate the string.

METHOD 2:

METHOD 3:

METHOD 4: ALTERNATIVE

METHOD 5:

Last updated