Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implicit declaration of function ‘strrev’ [duplicate]

Any ideas on why when I try to compile this code to check if a line from the file atadata I get the warning:

warning: implicit declaration of function ‘strrev’ [-Wimplicit-function-declaration]

CODE

#include <stdio.h>
#include <string.h>

int main(){
    char palindromes[100];
    char reverse[100];
    FILE *atadata = fopen("atadata","r");
    while (fgets(palindromes,sizeof(palindromes),atadata) != NULL){
        strcpy(reverse,palindromes);
        strrev(reverse);
        if( strcmp(atadata,reverse) == 0)
        fputs(atadata, stdout);
    }
    fclose(atadata);
    return 0;
}
like image 976
Sean O'Brien Avatar asked Jul 18 '26 02:07

Sean O'Brien


1 Answers

If you are compiling in Linux, then strrev() is not part of string.h. The linked question contains an answer linking to source for an implementation you can bring into your own code directly.

like image 139
Alex Reynolds Avatar answered Jul 19 '26 16:07

Alex Reynolds