这个fun函数中的有关指针q的代码是什么意思,求详细解释
//请编写一个函数fun,用来删除字符串中的所有空格。
#include <fstream>
using namespace std;
/********** Begin **********/
void fun(char *str)
{
char *p = str;
char *q;
while(*p!=0)
{
if(*p==' ')
{
q = p;
while(*q!=0)
{
*q = *(q+1);
q++;
}
}
else
p++;
}
}
/********** End ***********/
int main()
{
ifstream infile("in.txt",ios::in);//定义输入文件流类对象infile
ofstream outfile("out.txt",ios::out);//定义输出文件流类对象outfile
//infile、outfile用法与cin、cout一样
char str[81];
while(!infile.eof())
{
infile.getline(str,81);//读入一行字符串(可以有空格)
fun(str);
outfile<<str<<endl;
}
infile.close();
outfile.close();
return 0;
}