#include <stdio.h>
#include <string.h>
int main(void)
{
char *str[] = {"Hello world","Hello hell","hello aka","hello hello hoho"};
char src[32] = {0};
char *tmp = NULL;
int i;
int len = sizeof(str)/sizeof(str[0]);
while(1)
{
printf("Enter a string:\n");
scanf("%s",src);
if(!strcasecmp(src,"exit"))
return 0;
for(i = 0; i < len; i++)
{
tmp = str[i];
while((tmp = strstr(tmp,src)) != NULL)
{
printf("%s :row = %d col = %d\n",src,i,strlen(str[i]) - strlen(tmp));
tmp += strlen(src);
}
}
}
return 0;
}
確定一個字符串在規定的字符串中的行列位置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.