C Assigement
C Assigement
Program Overview
Code c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void displayMenu() {
printf("-------------------------------\n");
printf("3. Exit\n");
printf("-------------------------------\n");
printf("Command-Line Arguments:\n");
for (int i = 0; i < argc; i++) {
void askUserInput() {
char userInput[100];
int choice;
while (1) {
displayMenu();
scanf("%d", &choice);
switch (choice) {
case 1:
displayArguments(argc, argv);
break;
case 2:
askUserInput();
break;
case 3:
printf("Exiting...\n");
return 0;
default:
return 0;
Explanation
To compile and execute the program, save it in a file named cli_app.c and
use the following commands:
./cli_app
This will display the command-line arguments when you choose option 1
from the menu.