C language - characters in reverse order

1032: C language - Character reverse
subject description
written a function, so that a string in reverse order of the input is stored in the main function of the input string in reverse order output.

Input
line character
output
string in reverse order of
the sample input
123456abcdef
Sample Output
fedcba654321

# include<stdio.h>
# include<string.h>
void F(char ch[],int m); 
int main()
{
	int m;
	char ch[10000];
	gets(ch);
	m=strlen(ch);
	F(ch,m);
	puts(ch);
	return 0;
 } 
void F(char ch[],int m)
 {
 	int i;
 	char ch1;
 	for(i=0;i<m/2;i++)
 	{
 		ch1=ch[i];
 		ch[i]=ch[m-1-i];
 		ch[m-1-i]=ch1;
	 }
 }

Note: strlen calculated by subtracting a length to.

Published 123 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/Du798566/article/details/104871767