字符串解析

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

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 @ 2013-12-13 20:05  姚来飞  阅读(215)  评论(0)    收藏  举报