This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
sys_prog/revargs.c

24 lines
509 B
C
Raw Normal View History

2019-10-03 14:34:06 +00:00
// vim: set ts=4 sw=4 et tw=80:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool compare_reverse(char* s1, char* s2) {
const size_t len = strlen(s1);
if (len != strlen(s2))
return false;
for (size_t i = 0; i < len; i++)
if (s1[i] != s2[len - 1 - i])
return false;
return true;
}
int main (const int argc, char** argv) {
for (int i = 1; i < argc - 1; i++)
for (int j = i + 1; j < argc; j++)
if (compare_reverse(argv[i], argv[j]))
printf("%s %s\n", argv[i], argv[j]);
}