字符串解析

解析用空格分隔单词的字符串:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void Analysis(char string[])
{
    if(string == NULL)
    {
        return;
    }
 
    int index = 0;
 
    while(isspace(string[index]))
    {
        index++;
    }
 
    int startIndexOfWord = index;
    int endIndexOfWord;
 
    while(string[index] != '\0')
    {
        if(isspace(string[index]))
        {
            endIndexOfWord = index - 1;
            ParseWord(string,startIndexOfWord,endIndexOfWord);
             
            index++;
            while(isspace(string[index]))
            {
                index++;
            }
            startIndexOfWord = index;
        }
        else
        {
            index++;
        }
    }
}

  

posted @   姚来飞  阅读(203)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示