#include #include int comparestr(const char *, const char *); const char* getocc(const char *, char); int main(int argc, char *argv[]) { char test1[] = "This is a string"; char test2[] = "This is a string"; char test3[] = "This is another string"; char test4[] = "And this is not"; char test5[] = "Teste"; const char *a = getocc(test5, 'e'); printf("Test1 and test2: %s\n", comparestr(test1, test2) ? "not equal" : "equal"); printf("Test3 and test4: %s\n", comparestr(test3, test4) ? "not equal" : "equal"); printf("Tester getocc: %s\n", (*a == 0) ? "fant ikke!" : "fant!"); exit(EXIT_SUCCESS); } int comparestr(const char *a, const char *b) { while(*a == *b) { if (*(a++) == 0) return 0; b++; } return 1; } const char* getocc(const char *a, char c) { while (*a && *a != c) { if (*(a++) == 0) return 0; } return a; }