If you look at the warnings and errors, you'll see the following:
Compilation failed due to following error(s).
main.c:14:25: warning: implicit declaration of function ‘strrev’; did you mean ‘strsep’? [-Wimplicit-function-declaration]
14 | strcpy(mot_reverse, strrev(mot));
| ^~~~~~
| strsep
/usr/bin/ld: /tmp/cc9hnaOp.o: in function `main':
main.c:(.text+0xb6): undefined reference to `strrev'
collect2: error: ld returned 1 exit statusWhat the compiler is telling you here is that strrev() is not found. The linker can not link the program ("undefined reference"). The problem here is that this is a non-standard C function. If you scroll to the notes section, you can see it there:
Note: This is a non-standard function that works only with older versions of Microsoft C.
The standard C string library does not define strrev().
This is not the end of the world. You can just write your own strrev() implementation. :)
#include <string.h>
char * strrev(char * str)
{
if (!str || !*str) // The reverse of a NULL string or an empty string is itself.
return str;
// Starting two indices: left and right, keep moving the left toward the right (increment) and the right toward the left (decrement) as long as left is less than right
for (int left = 0, right = strlen(str) - 1; left < right; left++, right--)
{
// Swap the characters at the left and right positions
char tempChar = str[left];
str[left] = str[right];
str[right] = tempChar;
}
return str;
}