Advertisement
metalx1000

Working with Args

Nov 28th, 2012
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. #ifdef __unix__
  5. # include <unistd.h>
  6. #define clear() system("clear");
  7.  
  8. #elif defined _WIN32
  9. # include <windows.h>
  10. #define sleep(x) Sleep(1000 * x)
  11. #define clear() system("cls");
  12.  
  13.  
  14. #endif
  15.  
  16. int main(int argc, char *argv[]){
  17.  
  18.     char name[20];
  19.  
  20.     clear();
  21.  
  22.     if(argc < 2 ){
  23.         printf("Please Enter You Name: ");
  24.         fgets(name,sizeof(name),stdin);
  25.         sleep(2);
  26.     }
  27.     else{
  28.         strcpy(name, argv[1]);
  29.     }
  30.  
  31.     printf("Hello %s\n", name);
  32.     sleep(2);
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement