static int ls(int argc, char * argv[]) { int opt; struct option long_help[]= { {"all", 0, NULL,'a'}, {"directory", 0, NULL,'d'}, {"help", 0, NULL,'h'}, //{"human-readable", 0, NULL,'h'}, {"inode", 0, NULL,'i'}, {"reverse", 0, NULL,'r'}, {"recursive", 0, NULL,'R'}, {0,0,0,0}, }; /* Normal mode */ if (argc == 1) show_normal(); else { while ((opt = getopt_long(argc, argv, "adhirR", long_help, NULL)) != -1) { switch(opt) { default: break; } } } }
int main(int argc, char ** argv) { BOOK library[MAXBKS]; int count = 0; printf("Please enter the book title.\n"); printf("Press [enter] at the start of a line to stop.\n"); while(count < MAXBKS && fgets(library[count].title, MAXTITL, stdin) && library[count].title[0] != '\n') { reject_ch(library[count].title, '\n'); printf("Now enter the author.\n"); fgets(library[count].author, MAXAUTL, stdin); reject_ch(library[count].author, '\n'); printf("Now enter the value.\n"); scanf("%f", &library[count++].value); while(getchar() != '\n') continue; if(count < MAXBKS) printf("Enter the next title.\n"); } if(count > 0){ show_normal(library, count); BOOK * library_dup[count]; copy_arrp(library_dup, library, count); show_title_ASC(library_dup, count); show_value_ASC(library_dup, count); }else{ printf("No books?Too bad.\n"); } exit(EXIT_SUCCESS); }