Im new to getopt(), I have never used it before and i was just wondering what I am doing wrong here. Here is my code so far....
compiler error
Code:
[cat]$ make
gcc -Wall -ansi -pedantic kitty.c -o cat
kitty.c: In function âmainâ:
kitty.c:11: warning: implicit declaration of function âgetoptâ
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char * argv[])
{
char choice;
/*FILE * fptr;*/
while (( choice = getopt (argc, argv[1], "AbeEnstTuv")) != -1)
{
switch(choice)
{
case 'A':
printf("show all\n");
break;
case 'b':
printf("number nonempty output lines\n");
break;
case 'e':
printf("equivalent to -vE\n");
break;
case 'E':
printf("displays $ at end of each line\n");
break;
case 'n':
printf("number all output lines\n");
break;
case 's':
printf("supress repeated empty output lines");
break;
case 't':
printf("equivalent to -vT");
break;
case 'T':
printf("display TAB character as ^I");
break;
case 'u':
printf("ignored");
break;
case 'v':
printf("use ^ and M- notation, except for LFD and TAB");
break;
default:
fprintf(stderr, "%s is not a valid character", &choice);
exit(1);
}
}
return 0;
}