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;
}
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.