repo.or.cz
/
C-Programming-Examples.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Added stack address randomization example.
[C-Programming-Examples.git]
/
ex_4-1.c
blob
d02aa849bca3fcd471c19881cca9ab6b7962526c
1
#include <stdio.h>
2
3
/* finds las occurence of char t in string s */
4
int
strindex
(
char
s
[],
char
t
)
5
{
6
int
i
;
7
for
(
i
=
strlen
(
s
)-
1
;
i
>
0
;
i
--)
8
{
9
if
(
s
[
i
] ==
t
) {
return
i
; }
10
}
11
return
-
1
;
12
}
13
14
int
main
()
15
{
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
;
22
}