/** This program inverts the caracters in a given text file, using command line arguments or by prompting the question to the user. By Joni Silva, 27/05/2022. */ #include // Necessary to initalize my struct with all the info struct parameters info = { .filename = "EMPTY", .fd = NULL, .version = "1.0", .fileNameSize = 80, // Below is the variable that olds the text to dislpay for help .help = "\n\ ------------------------------------------------\n\ Usage: ./chcount -c []\n\ -help Print help and exit.\n\ -v Print application version and exit.\n\ -i Invert text caracters.\n\ Example: ./chcount -c test.txt\n", }; int main (int argc, char *argv[]) { if (argc == 1) { ask_file(); } else if (argc == 2) { if (strncmp(argv[1], "-help", 5) == 0) { printf("%s\n", info.help); } else if (strncmp(argv[1], "-v", 2) == 0) { printf("Version %s\n", info.version); } else { get_file(argv[1]); } } else if (argc == 3) { if(strncmp(argv[1], "-i", 2) == 0) { get_file(argv[2]); } else { printf("\nInvalid flag!!!"); printf("%s\n", info.help); } } else { printf("\nTo many parameters!!!"); printf("%s\n", info.help); } return 0; }