Reversing of string without using string
In this example, we will understand to perform Reversing of string without using string handling function and know how to write, compile and debug it in C language and also learn how to implement it in c.
As you know the best way to do this program is by using the strrev() function but in this example we reverse string manually without using any string handling function
In order to do this you will need
- Basic knowledge of c programming language.
- As well as know how to operate codeblocks.
So let's begin with our program
1.Open a codeblocks software.
2.Open new empty file.
3.Copy and paste the code from below.
Input code-
// program for reversing of string without using string handling function
#include <stdio.h>
int main()
{
char s[1000], r[1000];
int begin, end, count = 0;
printf("Input a string\n");
gets(s);
while (s[count] != '\0')
count++;
end = count - 1;
for (begin = 0; begin < count; begin++)
{
r[begin] = s[end];
end--;
}
r[begin] = '\0';
printf("%s\n", r);
return 0;
}
Now simply build the code. Look for any error. Now run the code.
For output enter any number or character series you want and press enter key.
Click the following button to download a program to perform string operations like string length without using string handling function
Thats it.Thank you for scrolling.
Tags:
string handling function