Question

You will be making a program that can take command like args. Using command line arguments,...

You will be making a program that can take command like args.

Using command line arguments, allow the program to do the following

If the command is -i, print: Integer, and then print the integer after it.

If the command is -f print: float, and then print the float after it

if the command is -s print: string, and then print the string after it.

If the command is -h print: all the commands, and the syntax

If the command is something not listed, do the same as the -h command.

It doesn't matter the number or the order -- do all the commands that the person typed.

Example entries into the program:

prog.exe -i 3

prog.exe -f 3.14 -i 6

prog.exe -i 6 -f 3.8

prog.exe -h

You will be making a program that can take command like args.

Using command line arguments, allow the program to do the following

If the command is -i, print: Integer, and then print the integer after it.

If the command is -f print: float, and then print the float after it

if the command is -s print: string, and then print the string after it.

If the command is -h print: all the commands, and the syntax

If the command is something not listed, do the same as the -h command.

It doesn't matter the number or the order -- do all the commands that the person typed.

extra credit:

Is someone does a command, but it is not the right syntax -- show the correct syntax.

Example entries into the program:

prog.exe -i 3

prog.exe -f 3.14 -i 6

prog.exe -h

Word document please. c program on visualstdios 2017

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <bits/stdc++.h> using namespace std; void printAllo cout<<All the valid commands are:<<endl: cout<<1. -i fintegercout<<The correct syntax is -s (stringAn: else if(c-h) cout<<The correct syntax is -hln return; int checklnt(string s) forreturn true; int main (int argc char *argvI) if(argc>0) int i-1; string inputargcl forint i=0;i<argci++) inpu炯;; while(i<argint x strcpy(charr, inputli+1].c_str0: cout< <Integer<<x<<endl: char charr[1024]: sscanf(char, %d, 80よ i-i+2: else if(inpuelse if(inputlih) printAllO: else printAllo: return 0; else printAlI0: return 0;

Add a comment
Know the answer?
Add Answer to:
You will be making a program that can take command like args. Using command line arguments,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that determines if a string (passed as a command-line argument) has all unique...

    Write a program that determines if a string (passed as a command-line argument) has all unique characters. The program must print the number of times each existing character appears, and then print whether or not they are all unique. Special requirements: You are NOT allowed to modify the input string or create any additional data structures (no arrays, lists, dictionaries, or other strings). You may have only one string (the one received as the command-line argument). You may have one...

  • In C, Write a program that can accept an arbitrary number of command line arguments, e.g....

    In C, Write a program that can accept an arbitrary number of command line arguments, e.g. program must do the following: program needs to split each of the arguments into two halves based on the length of a string. Specifically, the first half will be [0, n/2) and the second half will be [n/2] where n is the length of the string and n > 1. For instances, hello is split into two halves: he and llo. Similarly, world! is...

  • Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text...

    Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text file by removing all blank lines (including lines that only contain white spaces), all spaces/tabs before the beginning of the line, and all spaces/tabs at the end of the line. The file must be saved under a different name with all the lines numbered and a single blank line added at the end of the file. For example, if the input file is given...

  • The original code using the gets() function is written below. You need to do (a) change...

    The original code using the gets() function is written below. You need to do (a) change the provided code so that you now use fgets() function to obtain input from the user instead of gets(), (b) make any other necessary changes in the code because of using fgets() function, and (c) fill in the code for the execute() function so that the whole program works as expected (a simple shell program). Note: part c is already done, and the execute...

  • For our assignment we have to use four optional command line arguments through a makefile (which...

    For our assignment we have to use four optional command line arguments through a makefile (which says args= ${ss} ${nn} ${mm} ${pp}). They can leave out any of those variables they want, but if there is more than one they have to be in a certain order. The command line would read something like "make run2 ss=0" or "make run2 ss=0 nn=16 mm=3 pp=src" How do I use these variables in my main method? Can I just somehow use the...

  • Problem: Write a program that behaves as described below.If the first command-line argument after the program...

    Problem: Write a program that behaves as described below.If the first command-line argument after the program name (argv[1]) is “--help”, print the usage information for the program. If that argument is not “--help”, you are to expectargv[1]and subsequent arguments to be real numbers(C, integer, float, or double types)in formats acceptable to the sscanf()function of the C library or strings of ASCII chars that are not readable as real numbers. You are to read the numbers, count them and calculate the...

  • Update the program in the bottom using C++ to fit the requirements specified in the assignment....

    Update the program in the bottom using C++ to fit the requirements specified in the assignment. Description For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is “quit”, the program should immediately exit. If “quit” is not found, each of these lines of input will be treated as a command line to be executed. These...

  • Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arg...

    Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arguments shall consist of the following 1. The width (in pixels) of the image, as a positive decimal integer 2. The height (in pixels) of the image, as a positive decimal integer 3. The minimum area (in pixels) that a triangle must have in order to be drawn,...

  • In a linux command line Give AWK commands for accomplishing each of the following: Print the...

    In a linux command line Give AWK commands for accomplishing each of the following: Print the 2nd last field (the field directly before the last field) of each line from a file named 'last.txt' Assume you have a file called 'names' that contains a list of people, one person per line. Also, assume that on each line the 3rd field on that line contains the age of the person. Some of the people do not have an age listed, and...

  • C programming Question1 (a) Write a C program that will print out all command line arguments,...

    C programming Question1 (a) Write a C program that will print out all command line arguments, in reverse order, one per line. Prefix each line with its index. 6 marks] (b) Consider this C code snippet int a- 100 int b- 42; inte p- &a; int q-b; p qi printf ("%d %d\n" ,a,*p); When this code is executed, what numbers will it print? [2 marks] (c) Consider this C program int main(int argc,char argv) char* target- "Apple" char vord[100] printf...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT