Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //To use fgets and printf I need to include stdio header
- #include <string.h>
- //To use strlen I need to include string header
- #define MAXLINE 100 /* maximum input line length */
- int suffix(char str[], char c);
- /*
- The function suffix prints all the substrings that
- (1) starts with the letter stored in the variable 'c'
- (2) included in the string str[]
- Function should return the number of substrings.
- */
- int main()
- {
- char user_input[MAXLINE]; /* current input line */
- char ch = 0;
- int counter = 0;
- printf(" Please enter a string (up to 100 characters) and then press enter ");
- /*
- This will store a maximum of MAXLINE characters into the string from the standard input
- and it will ensure it is null-terminated.
- The fact that we've limited the input to the size of the array declared earlier
- ensures that there's no possibility of buffer overruns.
- */
- fgets(user_input, MAXLINE, stdin);
- //Then let's clear the pesky newline that's been entered into the string using strlen:
- user_input[strlen(user_input)-1] = '