/* * Author: D. Sheets * Description: Example of NULL character storage */ #include #define SIZE 10 int main() { /* Strings we will work with */ char str1[SIZE]; char str2[SIZE] = { '\0' }; /* Print initial values */ printf("1=%s\n", str1); printf("2=%s\n", str2); /* Fill in some data */ str1[0] = 'h'; str1[1] = 'e'; str1[2] = 'y'; printf("1=%s\n", str1); /* Now add the NULL */ str1[3] = '\0'; printf("1=%s\n", str1); /* Add the NULL another way */ str1[3] = ' '; str1[4] = 'b'; str1[5] = 'u'; str1[6] = 'd'; str1[7] = NULL; printf("1=%s\n", str1); /* Add the NULL a third way */ str1[7] = 'd'; str1[8] = 'y'; str1[9] = 0; printf("1=%s\n", str1); return(0); }