postheadericon Example of command line argument in C on Linux

args.c

#include "stdio.h"
void main(int c, char *argv[])
{
    int i;
    for(i=0;i<c;i++)
    {
        printf("\nargument[%d] : %s",i,argv[i]);    
    }
}



This code demonstrate how to use command line argument in c programming

To execute this code


  1. Open  Terminal
  2. Compile args.c
    • gcc -o args args.c
  3. Execute args.c
    • ./args hi this is a demo code


0 comments:

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.