填空题

请编写一个函数fun,函数的功能是删除字符串中的所有空格。

例如,主函数中输入"asd af aa 267",则输出为"asdafaaz67"

请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

void fun(char *str)

{

    int i=0;

    char *p=str;

    while(①)

    {

      if(②)

      {

        ③

      }

      ④

    }

    ⑤

}

main()

{

    char str[81];

    void NONO ();

    printf("Input a string:");

    gets(str);

    puts(str);

    fun(str);

    printf("*** str:%s\n",str);

    NONO();

}

void NONO ()

{/* 请在此函数内打开文件,输入调试数据,

 调用 fun 函数,输出数据,关闭文件。 */

    char str[81];

    int n=0;

    FILE *rf, *wf;

    rf=fopen("in.dat","r");

    wf=fopen("out.dat","w");

    while(n<8) 

    {

        fgets(str, 80, rf);

        fun(str);

        fprintf(wf, "%s", str);

        n++;

    }

    fclose(rf);

    fclose(wf);

    system("pause");

}

赣ICP备20007335号-2