Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int endsWith(const char* const str, const char* const end)
- {
- if(strlen(str) < strlen(end) || strcmp(str+strlen(str)-strlen(end), end)) return 0; //Zeiger Arithmetik damit str auf die gewünschte Endung zeigt.
- return 1;
- }
- int main()
- {
- char string[] = {"Test.txt"};
- char end[] = {".txt"};
- if(endsWith(string, end)) printf("Heureka!");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement