Advertisement
Guest User

Untitled

a guest
May 8th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int endsWith(const char* const str, const char* const end)
  6. {
  7.     if(strlen(str) < strlen(end) || strcmp(str+strlen(str)-strlen(end), end)) return 0; //Zeiger Arithmetik damit str auf die                                                 gewünschte Endung zeigt.
  8.     return 1;
  9. }
  10.  
  11. int main()
  12. {
  13.     char string[] = {"Test.txt"};
  14.     char end[] = {".txt"};
  15.     if(endsWith(string, end)) printf("Heureka!");
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement