Strings always end with the NULL character : String Introduction « String « C Tutorial






ASCII code for the NULL character is \0

#include <stdio.h>

int main(){

  char myname[4];
    myname[0] = 'D';
    myname[1] = 'a';
    myname[2] = 'n';
    myname[3] = '\0';

    printf("%s \n",myname);
}
Dan








3.1.String Introduction
3.1.1.Strings
3.1.2.A string is an array of characters.
3.1.3.Write string in a more traditional array style
3.1.4.Strings always end with the NULL character
3.1.5.String constants consist of text enclosed in double quotes
3.1.6.Useful string function