#include <stdio.h>
int findpos(char *str, char x);
int main(int argc, char **args)
{
[tab][/tab]char *s = "some gext";
[tab][/tab]int r;
[tab][/tab]r = findpos(s, 'g');
[tab][/tab]printf("%d\n", r);
}
int findpos(char *str, char x)
{
[tab][/tab]char *s = str;
[tab][/tab]int i = 0;
[tab][/tab]while (*s && (*s != x))
[tab][/tab]{
[tab][/tab][tab][/tab]++i; ++s;
[tab][/tab]}
[tab][/tab]return (*s) ? i : -1;
}
| |
|
Welcome to AstaHost - Dear Guest | |
Toggle shoutbox
Shoutbox
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||



