[Courses] [C] What is wrong here??
anand.r at cybertech.co.in
Tue Aug 13 18:49:09 EST 2002
I struggled for over an hour with this program trying to
clear my concepts on pointers, arrays, functions etc. I stumbled upon an
idea to write a program which will figure out whether a given string is a
palindrome or not. That was the simplest I could start with, guys.
a). I tried writing the palindrome program, the easy way and it has already
worked. Using a single for loop and then use the if condition.
b). I then decided to use string functions to conclude that a string is a
palindrome or not. I wanted to avoid using readymade functions for reversing
a string. So, thought of writing one. And that is where, things got badly
My purpose is to accept a string input from the user, and check whether it
is a palindrome or not. I tried hard to figure out how to write a C function
to reverse a string, and how to store this reversed value in another string.
If somebody could tell me where I am going wrong here. Any pointers to
understand this better would be greatly appreciated.
char strrev(char array);
fprintf(stderr,"\nEnter a string: ");
printf("\nThe reversed string is: %s\n",strrev(string1));
char strrev(char array)
register int i;
More information about the Courses