I really need help on this one. Can't believe getting this kind of question as a newbie to C programming. Thanks alot Write a program that takes 3 command-line arguments – the first is a flag, then second is a character, the third is a filename. If the flag argument is ‘s’ then it prints only those lines in the file that contain the character. If the flag argument is ‘-n’ then it prints only those lines in the file that do *not* contain the character.
and for more control about argument handling you can use getopt (from GNU). and else like Mahesh.Shetye said: Code: #include <stdio.h> int main(int argc, char *argv[]) { if(argc!=4){ printf("Usage: %s <flag> <char> <file>",argv[0]) return 0; } // remaining code here return 0; }