C Program Working with Args

How to write a C Program Working with Args ?


Solution:

#include<stdio.h>
#include<string.h>

#ifdef __unix__
# include <unistd.h>
#define clear() system("clear");

#elif defined _WIN32
# include <windows.h>
#define sleep(x) Sleep(1000 * x)
#define clear() system("cls");


#endif

int main(int argc, char *argv[]){

    char name[20];

    clear();

    if(argc < 2 ){
        printf("Please Enter You Name: ");
        fgets(name,sizeof(name),stdin);
        sleep(2);
    }
    else{
        strcpy(name, argv[1]);
    }

    printf("Hello %s\n", name);
    sleep(2);

}

C Program Quadratic equation


Learn More :