strcspn

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
	char dst[] = "abcdefgh";
	char *src = "xyzd";
	unsigned char map[32] = {'0'} ;


	printf("%d", strcspn(dst, src));
	return 0;
}

输出:

3

strcspn查找对于dst,第一个出现在src中的字符下标。

上面dst中的字符d是第一个出现在src中的字符,其下标为3.

posted @ 2012-12-06 16:00  helloweworld  阅读(134)  评论(0编辑  收藏  举报