下列给定程序中,函数fun的功能是:将P所指字符串中的所有字符复制到b中,要求每复制3个字符之后插入一个空格。
例如,若给a输入字符串:“ABCDEFGHIJK”,调用函数后,字符数组b中的内容为:“ABC DEFGHI JK”。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char*p,char*b)
(int i,k=0;
while(*p)
i=1;
while(i<=3&&*p)
/********found********/
b[k]=p;
k++;p++;1++;
if(*p)
/********found********/
b[k++]=…"";
b[k]=’\0’;)
main()
(char a[80],b[80];
printf("Enter a string:");
gets(a);
printf("The original string:");
puts(a);
fun(a,b);
printf("\nThe string after insert space:");
puts(b);printf("\n");