Write and show how you would compile and run a C program that uses command line arguments in the terminal.
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
Get Answers For Free
Most questions answered within 1 hours.