Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

What advancement barriers is Marina encountering?

Answered: 1 week ago

Question

Question What is a Roth 403 (b) plan?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago