Displaying ./code/feb21/string3.c#include <stdio.h> #include <stdlib.h> #include <string.h> #define BUF 512 int main(int argc, char **argv){ char firstArg[BUF]; if(argc < 2) strcpy(firstArg, "No Arguments Given\n"); else strcpy(firstArg, argv[1]); if(firstArg[0] == '-'){ printf("option detected\n"); if(strchr(firstArg, 'a') != NULL) printf("found an a\n"); } for(int i = 1; i < argc; i++){ printf("argv[%d]: %s\n", i, argv[i]); } return 0; } |