Uses a command line argument. - C Function

C examples for Function:main function

Introduction

It prints Hello and your name on the screen, if you specify your name as a command line argument.

Demo Code

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
   if (argc != 2) {
      printf("You forgot to type your name.\n");

      exit(1);//from   www  .  j a  v a 2  s.com

   }
   printf("Hello %s", argv[1]);

   return 0;

}

Related Tutorials