Question: Modify the C program so that input characters are command line arguments. #include #include int main ( ) { char ch; int valid = 1

Modify the C program so that input characters are command line arguments.
#include
#include
int main(){
char ch;
int valid =1;
printf("Enter input: ");
while ((ch = getchar())!='
'){// scan input
if (isalpha(ch)){// checks for capital
if (!islower(ch)){// checks for lowercase
valid =0;
break;
}
} else if (!isdigit(ch) && ch !='' && ch !='!' && ch !='?' && ch !='.'){// if anything else than invalid
valid =0;
break;
}
}
Input characters are command line argument.
Character handling library functions in ctype.h are allowed.
The program should also check if the number of arguments on the command line is greater than 2(including ./a.out as one of the arguments). If the number of arguments is not greater than 2, the program should print "invalid number of arguments".
Follow the format of the examples below.
Examples (your program must follow this format precisely)
Example #1
$ ./a.out spring_24
invalid
Example #2
$ ./a.out 8 little pigs!
valid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!