Wednesday, 25 October 2017

Print Your Name Using Command Line Argument

#include<stdio.h>
int main(int argc, char * argv[])
{
      int i;
      if(argc==1)
      {
            printf("You need to enter your name");
            exit(1);
      }
      for(i=1;i<argc;i++)
      {
            printf("%s",argv[i]);
      }
      return 0;
}

OUTPUT:  programName  XYZ ↵ (enter)
                    XYZ

1 comment:

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...