Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #include <string.h>
- #define MAX_STR_LEN 100
- #define MAX_STR_COUNT 100
- bool strend(char *s, char *end)
- {
- int i, j;
- bool isEnd = true;
- for (i = strlen(s), j = strlen(end); i >= 0 && j >= 0 && isEnd; i--, j--)
- isEnd = s[i] == end[j];
- return isEnd;
- }
- int main(int argc, char *argv[])
- {
- char s[MAX_STR_COUNT][MAX_STR_LEN], end[MAX_STR_LEN];
- int i = 0, j = 0;
- if (argc > 1)
- strcpy(end, argv[1]);
- else
- {
- printf("Enter template: ");
- scanf("%s", end);
- }
- while (scanf("%s", s[i++]) != EOF);
- printf("\n");
- for (j = 0; j < i; j++)
- if (strend(s[j], end))
- printf("%s\n", s[j]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment