How to Create Your Own Command in C

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

#include<stdio.h>
#include<conio.h>
int main(int argc,char *argv[])
{
    if(argc==2)
    {
      FILE *fp=NULL;
      fp=fopen(argv[1],"r");
      if(fp==NULL)
        printf("File not found");
    else
    {
          char ch;
          while(((ch=fgetc(fp))!=EOF))
          {
              printf("%c",ch);
          }
          fclose(fp);
    }

    }
    else
      printf("Invalid command...."); 


}

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *