C language programming> twenty-sixth week② The function of the function fun in the following given program is to output the contents of the string in reverse order, but does not change the contents of the string.

Example: The function of the function fun in the following given program is to output the contents of the string in reverse order without changing the contents of the string.

例如,若字符串为asdf,则应输出fdsa。
注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。

代码如下:

#include<stdio.h>
void fun(char*s)
{
    
    
	if(*s)
	{
    
    
		fun(s+1);
		printf("%c",*s);
	}
}
main()
{
    
    
	char str[10]="asdf";
	printf("do string=%s\n after=",str);
	fun(str);
	printf("\n");
}

The output running window is as follows:
Insert picture description here

越努力越幸运!
加油,奥力给!!!

Guess you like

Origin blog.csdn.net/qq_45385706/article/details/113306793