掌叔
2008-06-17 09:44:59
摘自:Etual.cublog.cn
/************************************************
Etual
2007-10-22
*************************************************/
#include
#include
#include
typedef char *POINT;
int len(char *str)
{
int length=0;
while (*str++ != ' '){
length++;
}
return length;
}
int find(char *str,char ch)
{
char *pos=str;
while ((*str++ != ch)&&(*str++ != ' ')){
return (int)(str-pos);
}
return 0;
}
int main(void)
{
char A[20]="I am in China";
POINT q=A;
printf("%s
",q);
printf("length is:%d
",len(A));
printf("position is:%d
",find(q,'a'));
return 0;
}