Added an example with a struct.
[C-Programming-Examples.git] / ex_4-1.c
blobd02aa849bca3fcd471c19881cca9ab6b7962526c
1 #include <stdio.h>
3 /* finds las occurence of char t in string s */
4 int strindex(char s[], char t)
6 int i;
7 for(i = strlen(s)-1; i > 0; i--)
9 if(s[i] == t) { return i; }
11 return -1;
14 int main()
16 char s[] = "sdgtwerlsjkadsfs";
17 char t = 's';
18 int pos = 0;
19 pos = strindex(s,t);
20 printf("POS Found: %d\n", pos);
21 return 0;