自定义函数delspace是怎么做到删除空格的
											
程序代码:
#include <stdio.h>
void delspace(char *p1);
int main(void)
{
    char str[81];
 do
 {
  puts("input a string:");
  gets(str);
  delspace(str);
  puts(str);
  puts("input any char except q to go on.");
  gets(str);
 }
 while(*str != 'q');
 puts("Quit.");
    return 0;
}
void delspace(char *p1)
{
 char *p2;
 while (*p1 != '\0' )
 {
  if (*p1 == ' ')
  {
   p2 = p1;
   while(*p2 != '\0')
   {
    *p2 = *(p2+1);
    p2++;
   }
   p1--; //抵消下面的p1++
  }
  p1++;
 }
}
有谁能跟我解释一下delspace函数中到底是怎么运行的?每一行代码都懂,放在一起就没办法理解。



											
	    

	

