Add help message for rev command usage

This commit is contained in:
Jan 2026-05-15 16:53:59 +02:00 committed by GitHub
parent 22530a31b1
commit e5504c15f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,6 +23,12 @@ int main(int argc, char *argv[]) {
printf("Wrong input, use --help for more info\n");
return 1;
}
if (argc == 2 && strcmp(argv[1], "--help") == 0) {
printf("Reverses the contents of a file or text\n");
printf("Usage: rev [file]\n");
printf(" echo text | rev\n");
return 0;
}
FILE *fp = fopen(argv[1], "r");
// check if the argument is a file or not by opening it