Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- const int SIZE = 10;
- int main()
- {
- char line[SIZE] = {'\0'};
- printf("Enter string: ");
- fgets(line, SIZE, stdin);
- printf("String entered was: %s.\n", line);
- printf("String length is %d.\n", strlen(line));
- printf("Array's defined size is %d.\n", SIZE);
- printf("Array's actual size is %d.\n\n", sizeof(line));
- printf("Removing the new line character...\n\n");
- line[strlen(line) - 1] = '\0';
- printf("String entered was: %s.\n", line);
- printf("String length is %d.\n", strlen(line));
- printf("Array's actual size is %d.\n", sizeof(line));
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment