#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.

相关文章:

猜你喜欢
  • 2021-07-13
  • 2021-07-04
  • 2021-06-16
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案