By setting first[4] to NULL ('\0'), we can shorten the string : String Terminator « String « C Tutorial






#include <string.h>
    #include <stdio.h>

    int main()
    {
        char name[30];

        strcpy(name, "Saaaaaaaaaaaaaaam");

        printf("The name is %s\n", name);

        name[4] = '\0';

        printf("The name is %s\n", name);

        return (0);
    }
The name is Saaaaaaaaaaaaaaam
The name is Saaa








3.2.String Terminator
3.2.1.Displaying a string with a string terminator in the middle
3.2.2.Overwrite the newline character in string
3.2.3.By setting first[4] to NULL ('\0'), we can shorten the string