I am unable to locate the cause of the segmentation fault objective-to reverse a string using pointers
#include<stdio.h>
#include<string.h>
void swap(char *ptr[], int c)
{
int i;
char *r[40];
for(i=0; i<c; i++)
*(r[c-i]) = *(ptr[i]);
printf("%s",*r);
}
main()
{
int i;
char *ptr[20],str[40];
printf("enter string:");
gets(str);
for(i=0; i<(strlen(str)); i++)
ptr[i]=&(str[i]);
swap(ptr,strlen(str));
}