Question
Hello i did this program in C language, to reverse a string, it does not build and i dont know what is the issue. thanks
Hello i did this program in C language, to reverse a string, it does not build and i dont know what is the issue. thanks for your help
#include
void reverse(char *); void Lab9c() { char str[50]; char *ptr; printf("Enter a string: "); gets(str); reverse(str); printf("Reversed String is %s ", str);
return 0;
}
void reverse(char *string){ char temp, *begin, *end; begin = string; end = string; for (;*end != '\0'; end++){//the pointer temp points to the last element now } temp--; for (; begin >= end; begin++, end--){ temp = *end; *end = *begin; *begin = temp; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started