Reputation: 13
I wrote a simple code to reverse a string and its somehow not returning any result. Could someone please help me understand the problem.
#include <stdio.h>
#include <string.h>
void reverse_character(char *s){
int i;
int p = strlen(s);
for(i=(p-1);i<0;i--){printf("%c",s[i]);}
}
int main(){
char name[20];
printf("Enter a name");
scanf("%s",name);
reverse_character(name);
}
Upvotes: 1
Views: 41