Example: Please add the main function. The function of this function is to input a character string from the keyboard and store it in character s1, and store the odd-numbered characters in character string s1 in character string s2 and output it.
例如,当s1= “asdfgh”时,则s2= “sfh”。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
代码如下:
#include<stdio.h>
#include<conio.h>
#define N 80
main()
{
char s1[N],s2[N];
char*temp1=s1,*temp2=s2;
int i=0,j=0;
printf("Please Enter the string:");
scanf("%s",s1);
printf("\nThe original string is:");
while(*(temp1+j))
{
printf("%c",*(temp1+j));
j++;
}
for(i=1;i<j;i+=2)
*temp2++=*(s1+i);
*temp2='\0';
printf("\n\nThe new string is:%s\n",s2);
}
The output running window is as follows:
越努力越幸运!
加油,奥力给!!!