比如my name is jorze 怎麼獲取這個句子中所有單詞在句子中的起止位置
char buf[100] = {0};
gets(buf);
int n =strlen(buf);
char out[10][100] = {0};
int j = 0,k = 1;
for (int i = 0;i < n;i ++)
{
if (buf[i] >= 'a' || buf[i] <= 'z' || buf[i] >= 'A' || buf[i] <= 'Z')
{
out[j][k++] = buf[i];
}
if (buf[i] == ' ')
{
out[j][k - 1] = i;
j ++;
out[j][0] = i;
k = 1;
}
}
判斷字符,以空格為分割點。。數據保存在二維數組當中。。數組表示,起始位 + 字符串 + 結束位