// strlen example // Get string length // source: http://www.cplusplus.com/ #include #include #include #define SIZE 256 int main() { char input[SIZE]; char array1[]=""; char array2[]="1"; printf ("array1 is %u characters long.\n",(unsigned)strlen(array1)); printf ("array2 is %u characters long.\n",(unsigned)strlen(array2)); printf("now enter a sentence: "); fgets(input, sizeof(input), stdin); // A newline character makes fgets stop reading, but it is considered a valid // character by the function and included in the string copied to str. printf ("The sizeof input is %u characters long.\n",(unsigned)sizeof(input)); printf ("The strlen in input is %u characters long.\n",(unsigned)strlen(input)); return EXIT_SUCCESS; }