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'?
Write a C program that creates (or spawns) a child process to execute the Unix's command...
Write a C program that creates (or spawns) a child process to execute the Unix's command (echo) with a string as the command-line argument; while the program itself (the parent process) will execute another Unix command less with a filename as the command-line argument. If you aren't sure how the echo and less commands are meant to behave, experiment with them by running them directly from the command line first.
Write a C/C++ program that performs the tasks described below. If there is just 1 command-line...
Write a C/C++ program that performs the tasks described below. If there is just 1 command-line argument and it is -hw you should simply print hello world and then exit(0). Otherwise, the program should provide a function named mm_alloc. This is the function prototype: void *mm_alloc(int num_bytes_to_allocate) mm_alloc function should obtain space for the user from a block which you obtain via mmap. You should obtain the block on the first invocation and the block size should be some number...
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 program that runs on ocelot for a mini calculator using only the command...
Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line. The calculator will only do addition, subtraction, multiplication, division, and a power of 2. Usage: minicalc [-a num] [-d num] [-m num] [-s num] [-x] value • The variable value is the starting value. • Value should be validated to be an integer between 1 and 50 inclusive. Error message and usage shown...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • What new items will you need to replace a failing processor? Select all that apply.   ...
    asked 3 minutes ago
  • A system is to be developed for an airport. When passengers have boarded an aircraft, a...
    asked 11 minutes ago
  • After reading Module 5 PowerPoint 1 - The Philosophy of Human Existance and Health Care Policy,...
    asked 19 minutes ago
  • 1. Do you feel play has a place in supporting literacy development in early childhood? Explain...
    asked 23 minutes ago
  • How should roles be selected for the Emergency Operations Center (EOC)?  Is seniority less important than experience?...
    asked 36 minutes ago
  • Discuss routing issues and solutions namely, count-to-infinity, split horizon, split horizon with poison reverse, and hold-down...
    asked 36 minutes ago
  • Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is〈5,10,3,12,5,50,6〉.
    asked 1 hour ago
  • Water at 60 F (density=62.4lbm/ft^3 and dynamic viscosity = 7.5x10^-4 lbm/ft-s) is to be pumped through...
    asked 1 hour ago
  • ibuprofen an aspirin substitute has the following percent composition C, 75.69%; H,8.80%; O,15.51%. determine the empirical...
    asked 1 hour ago
  • Describe in brief some of the aspects of understanding words in the study of language
    asked 1 hour ago
  • Anticipated sales for Safety Grip Company were 75,000 passenger car tires and 23,000 truck tires. Rubber...
    asked 1 hour ago
  • QUESTION ONE a) Differentiate between traceable and common costs b) Assume that you are living in...
    asked 1 hour ago