C语言字符串查找函数 find(str, sub) 实现及测试用例
以下是一些可能的测试用例:
char str[] = 'hello world'; char sub[] = 'world'; int result = find(str, sub); // result 应该等于 6
char str2[] = 'hello world'; char sub2[] = 'goodbye'; int result2 = find(str2, sub2); // result2 应该等于 -1
char str3[] = 'hello world'; char sub3[] = ''; int result3 = find(str3, sub3); // result3 应该等于 0
char str4[] = ''; char sub4[] = 'hello'; int result4 = find(str4, sub4); // result4 应该等于 -1
原文地址: https://www.cveoy.top/t/topic/n93l 著作权归作者所有。请勿转载和采集!