透彻理解
程序代码:#include <stdio.h>
#include <ctype.h>
void word(char *p);
int main(void)
{
char a[81];
puts("input your string:");
gets(a);
word(a);
puts(a);
return 0; }
void word(char *p)
{ int begin,end;
for(begin=0; isspace( *(p+begin) ) ;begin++)
continue;
for(end=begin; !isspace( *(p+end) ) ;end++)
continue;
*(p+end) = '\0';
for(; *(p + begin) != '\0'; p++)
*p = *(p + begin);
*p = '\0'; }
题目要求:读取输入行里的第一个单词到数组,并丢掉该行中其他的字符 一个单词的定义是:一串字符,其中不含空格、制表符和换行符。
理解不够透彻 总有的似懂非懂的感觉。大神帮忙讲一下原理。[ 本帖最后由 破碎的石头 于 2012-12-31 12:16 编辑 ]










呵呵