Modify program so that input comes in as command line arguments. Sample run: ./a.out W8 4 ME 2...

70.2K

Verified Solution

Question

Programming

Modify program so that input comes in as command linearguments.
Sample run:
./a.out W8 4 ME 2 finish 2!
Output:
Consonants: WMfnsh


1) Name your program command_consonants.c.

2) If no command line arguments was provided, your program shouldprint a usage message “Usage: ./a.out input

#include

int main()
{
printf(\"Input: \");
int i = 0;
char ch;
// array to store consonants
char consonant[100]={\"\"};
//do loop to take input
do
{
ch = getchar();
//checks to see if consonants or not
if(((ch >= 'a' && ch <= 'z')||(ch >= 'A'&& ch <= 'Z')) && !(ch == 'a' || ch == 'e' || ch== 'i'|| ch == '0' || ch == 'u' || ch == 'A' || ch =='E'|| ch=='I'|| ch =='O' || ch == 'U'))
{
consonant[i] = ch;
i++;
}
  
}
while(ch != '\n');
  
printf(\"Consonants:\");
printf(\"%s\", consonant);
  
return 0;
}

Answer & Explanation Solved by verified expert
4.0 Ratings (400 Votes)
CODE includeint mainint argc char argvint i 0char ch    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students