Use of Command Line Arguments

Get introduced to the applications of command line arguments.

We'll cover the following

File copying

The command line arguments allow us to copy the contents of any file mentioned by the user on the command line. Let’s understand this with the help of an example program.

Example program

We have provided the source for the C program. When you press the RUN button, it will open the terminal for you. RUN the following commands in the given terminal to compile and execute the given program:

  • gcc -w main.c -o main
  • ./main main.c new.c

Later, we can see the content of the newly created file using the following command:

  • cat new.c

Get hands-on with 1200+ tech skills courses.