File to upper case using command line arguments

File to upper case using command line arguments

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

File to upper case using command line arguments
File to upper case using command line arguments

Write a C program to File to upper case using command line arguments

PROGRAM: File to upper case using command line arguments

/* File to upper case using command line arguments */

#include<stdio.h>
int main(int n,char *a[])
{
 int c;
 FILE *fr,*fw;

 if(n!=3)
 {
  printf("Invalide numbers of arguments.");
  return 1;
 }

 if((fr=fopen(a[1],"r"))==NULL)
 {
  printf("File can't be open.");
  return 1;
 }
 if((fw=fopen(a[2],"r+"))==NULL)
 {
  printf("File can't be open.");
  fclose(fr);
  return 1;
 }
 while(1)
 {
  c=fgetc(fr);
  if(feof(fr)) break;
  c=~c;
  fputc(c,fw);
 }
 fclose(fr);
 fclose(fw);
 return 0;
}

Leave a Reply

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