编写函数fun将字符串中的前导*号全部移到字符串的尾部

######从第二个while开始的代码是什么意思?

//请编写函数fun将字符串中的前导*号全部移到字符串的尾部。
//假定输入的字符串中只包含字母和*号。
//如:in.txt
//*******A*BC*DEF*G****
//则:out.txt
//A*BC*DEF*G***********
#include <fstream>
using namespace std;

/**********  Begin  **********/
void fun(char *s)
{
    char *p=s,*q; 
    while(*p=='*')
    {
        q = p;
        while(*q!=0)
        {
            *q = *(q+1);
            q++;
        }
        *(q-1) = '*';
    }
} 

/**********   End  ***********/

int main()
{   
    ifstream infile("in.txt",ios::in); //定义输入文件流类对象infile 
    ofstream outfile("out.txt",ios::out);//定义输出文件流类对象outfile
    //infile、outfile用法和cin、cout一样 
    
    char s[81];
    while(infile>>s)
    {
        fun(s);
        outfile<<s<<endl;
    }

    infile.close();
    outfile.close();
    return 0;
}