/*************************************************************
FileName : testStrSpace.cpp
FileFunc : 以空格来分割一个字符串里字符
Version : V0.1
Author : Sunrier
Date : 2011-09-23
Descp : 比如:qwe 982 uowop 24554
返回:
qwe
982
uowop
24554
*************************************************************/
#include <stdio.h>
#include <string.h>
typedef char cTYPE;
typedef unsigned char ucTYPE;
typedef int iTYPE;
typedef unsigned int uiTYPE;
#define MAX 100
#define LINE 100
#define ROW 100
int main( void )
{
ucTYPE ucStr[MAX] ="qwe 982 uowop 24554";
ucTYPE ucData[LINE][ROW];
uiTYPE uiCount = 0, uiLine = 0, uiRow = 0,uiI;
memset(ucData,0,sizeof(ucData));
while( '\0'!=ucStr[uiCount] )
{
if( ' '!=ucStr[uiCount] )
{
ucData[uiLine][uiRow] = ucStr[uiCount];
++uiRow;
++uiCount;
}
else
{
ucData[uiLine][uiRow]='\0';
++uiLine;
uiRow = 0;
++uiCount;
}
}
//test print informaiton
//printf("uiLine = %d\n",uiLine);
for( uiI=0 ;uiI<=uiLine ;uiI++)
{
printf("%s ",ucData[uiI]);
printf("\n");
}
return 0;
}
以空格来分割一个字符串里的字符
最新推荐文章于 2023-06-11 22:57:53 发布