Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "string.h"
- #define COL 128
- #define LEN 128
- int strend(char *, char*);
- int main(int argc, char* argv[])
- {
- char arr[COL][LEN];
- int i = 0;
- if (argv[1]) {
- //выход по EOF
- printf("%s\n", "Введите строки, в которых будем искать:");
- while (fgets(arr[i], LEN, stdin) != NULL){
- i++;
- }
- for (int j = 0; j < i; j++) {
- if (strend(arr[j], argv[1]) == 1) {
- printf("Строка подходит: %s", arr[j]);
- }
- }
- } else{
- printf("%s", "Введите шаблон через консоль");
- return 1;
- }
- return 0;
- }
- int strend(char *str, char *temp){
- int temp_len = (int)strlen(temp);
- int str_len = (int)strlen(str);
- char str1[LEN];
- int j = 0;
- if (strlen(str) >= strlen(temp)){
- for (int i = str_len - temp_len - 1; i < str_len; i++){
- str1[j] = str[i];
- j++;
- }
- str1[j-1] = '\0';
- if(strcmp(str1, temp) == 0){
- return 1;
- } else
- return 0;
- } else
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement