Answer to Question #187404 in C for Rubayet Adbir

Question #187404

Implement the following function which accepts a string as parameter and reverses it, without using any function


from the string library.


void strReverse(char *str)


1
Expert's answer
2021-04-30T00:25:16-0400
#define MAX_LEN	500


void strReverse(char *str)
{
	int n=0,k;
	char temp[MAX_LEN];
	while(*(str+n)!='\0') n++; 
	for(k=0;k<n;k++) temp[k] = *(str+n-k-1);
	printf("\n\nString in reverse order: %s",temp);
}


main(void)
{
	char InputStr[MAX_LEN];
	printf("\nEnter text/string: "); 
	scanf("%[^\n]",InputStr);	
	strReverse(&InputStr[0]);
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS