Sunday, 21 February 2016

Filehandeling in c++

Q) Program in C++ to read a text file and convert all letters into uppercase and save on another text file.

#include<iostream>
#include<stdio.h>
using namespace std;

void uppercase()
{char p;
char chi;
    FILE *fp;
    FILE *rp;

    fp=fopen("rem.txt","r");
    rp=fopen("mem.txt","w");
    char ch =getc(fp);

    while(ch!=EOF)
    {

        if(97<=ch&&ch<=122)
        {p=ch;
           p=p-32;
           cout<<p;
        putc(p,rp);
        }

      else
        {  chi=ch;
        cout<<ch;
        putc(chi,rp);
      }
 ch=getc(fp);

    }}
int main()
{
  uppercase();
   
return 0;
}

No comments:

Post a Comment