新手求带。。想了两天了
#include <stdio.h>#define MAX 100
int IsNumIn(char word[]);
int IsSpcIn(char word[]);
void Trim(char oldWord[], char newWord[]);
void Seg(char words[], char wArray[][100] );
int main()
{
char word[MAX];
char word1[MAX]={0};
char word2[MAX][MAX]={0};
gets(word);
Trim(&word[MAX], &word1[MAX]);
if (IsNumIn(&word1[MAX]))
{
printf("error");
}
else
{
if (IsSpcIn(&word1[MAX]))
{
Seg(&word1[MAX], &word2[MAX][MAX]);
puts(word2[MAX][MAX]);
}
else
puts(word1);
}
return 0;
}
int IsNumIn(char word[])
{
int i;
for(i=0; word[i]!='\0'; i++)
if(word[i]>='0' && word[i]<='9')
return 1;
return 0;
}
int IsSpcIn(char word[])
{
int i;
for(i=0; word[i]!='\0'; i++)
if(word[i]==' ')
return 1;
return 0;
}
void Trim(char oldWord[], char newWord[])
{
char *pold={0}, *pnew={0};
pold=oldWord;
pnew=newWord;
while (*pold!='\0')
{
if (*pold==' ' || *pold=='\n' || *pold=='\t')
*pold++;
else
break;
}
while (*pold!='\0')
*pnew++ = *pold++;
for (*pnew='\0', *pnew--; *pnew==' ' || *pnew=='\n' || *pnew=='\t'; *pnew--)
*pnew = *pnew+1;
++*pnew;
*pnew= '\0';
}
void Seg(char words[], char wArray[][100] )
{
int i, j, k;
for (i=0, j=0, k=i; words[i]!='\0'; i++, k++)
{
if (words[i]==' ')
{
j+=1;
k=-1;
}
else
wArray[j][k]=words[i];
}
}
哪些地方有问题。。