Question

Write and show how you would compile and run a C program that uses command line...

Write and show how you would compile and run a C program that uses command line arguments in the terminal.

Homework Answers

Answer #1

Program:

#include <stdio.h>

int main(int argc, char** argv)
{
int i;
printf("Give command line args: \n");
  
for (i = 1; i < argc; ++i)
printf("%s ",argv[i]);
  
return 0;
}

We will compile program and runs , Hello World Good morning are argument and a.out is program name

Compile:

g++ main.c

Run:

$./main Hello World Good morning
Know the answer?
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
Similar Questions
In Java, Write a small program that gets some numbers as command line arguments and finds...
In Java, Write a small program that gets some numbers as command line arguments and finds the minimum of those numbers. You can assume that the user will provide some command line arguments when running the program (so you don’t have to worry about what to do if the user doesn’t provide any arguments -- that won’t happen). Also, you can assume that all the command line arguments will be floating-point numbers, i.e., numbers with a decimal point, like 8.25.
How to use command line argument in python to write a program implement linux command 'find'?
How to use command line argument in python to write a program implement linux command 'find'?
Compile and run the following code and presuming your executable is in a.out, run this command...
Compile and run the following code and presuming your executable is in a.out, run this command from the shell prompt: ./a.out ; echo "Parent Terminated Normally with a return value of $?" Explain, in your own words, why you see the screen output you do and how that output relates to both the content of the program AND the nature of the shell command used to invoke it. Hint: This has everything to do with how processes “communicate” their exit...
write a C program that takes a floating-point value from the command line. This value is...
write a C program that takes a floating-point value from the command line. This value is interpreted to be a fuel consumption reading in Miles/Gallon. The program returns the fuel consumption in Liters per 100 Kilometer. The prototype declaration of the function implementing this looks like this: float mpg_to_lp100k(float mpg);
Write a C Language program called iam.c to: Have a string variable called myName initialized to...
Write a C Language program called iam.c to: Have a string variable called myName initialized to your-name-here.  Print on one line a literal string "Hello " concatenated to myName. In Linux Terminal compile your iam.c source code program to produce a .exe executable. Run your iam.exe and take a print screen image. Upload your iam.exe file here.
Your program, called should take two command line arguments, the dictionary, and the text that you...
Your program, called should take two command line arguments, the dictionary, and the text that you wish to spellcheck. Provide some sample text. Your program should be case insensitive (so you can toLower everything). Numbers and contractions are considered valid words. You may use the java HashTable or HashMap to implement this program; but it must use some kind of hash table.
Q.6) What does it mean if you compile your C# source code file and you only...
Q.6) What does it mean if you compile your C# source code file and you only get copyright information about Microsoft as a response? a) You have not set the path to the compiler correctly. b) Your program has syntax errors that you must correct before you can compile the program. c) The compiler cannot find the source code file that you are trying to compile. d) The compiler successfully compiled your program. Q.4) To compile a C# source code...
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
You shall write a Java program that functions similarly to the GNU strings utility. Your program...
You shall write a Java program that functions similarly to the GNU strings utility. Your program must: 1.Accept any number of command-line arguments, assumed to be file paths. -If the first command-line argument can be parsed as an integer, this integer shall represent the minimum sequence length. Otherwise, the minimum sequence length shall be 4 strings. 2.Print, one per line, to standard output, all printable character sequences that are at least as long as the minimum sequence length and are...
Write a program in C that uses recursion to calculate and print the factorial of the...
Write a program in C that uses recursion to calculate and print the factorial of the positive integer value passed in or prints the line "Huh?" if no argument is passed or if the first argument passed is not a positive integer. If the value passed in exceeds 10, you can simply print "Overvalue".
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT