I do not know where the error is. Every time I compile accuse segmentation fault (core dumped) error, can anyone help me? The code is here:
#include <stdio.h>
int strlen(char *s);
char *strrev(char *s);
int main() {
char frase1[30+1];
char frase2[30+1];
printf("Digite uma frase: ");
gets(frase1);
printf("Digite outra frase: ");
gets(frase2);
printf("Frase 1 = %s\n", strrev(frase1));
printf("Frase 2 = %s\n", strrev(frase2));
return 0;
}
int strlen(char *s) {
int i;
while(s[i]) {
i++;
}
return i;
}
char *strrev(char *s) {
int i, len;
char aux;
for(i=0,len=strlen(s)-1; i<len; i++, len--) {
aux = s[i];
s[i] = s[len];
s[len] = aux;
}
return s;
}