Reverse String in C

Below is a C program that will reverse (input) text.

#include<stdio.h>

int main(){
	int length = 0;
	char name[30];
	printf("enter your name: ");
	scanf("%[^\n]", name);

	//determine the length of the string
while(name[length] != '\0') length ++; while(length >= 0){ printf("%c", name[length]); length --; } return 0; }

 

output:

reverse string

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.