Hello!
I am having problems to copy the output of a text file to another one. The aim of this small program is to convert a sentence in lowercase stored in a file to uppercase and store the output to another txt file. finally display the output..Plz help me

#include <cstdlib>
#include <iostream>
#include <fstream.h>

using namespace std;

int main()
{
    int i ;
    char sentence[100];
    ifstream streamin;
    fstream streamout;
            
    
    streamin.open("test.txt");    
            
              
    cout<< " The sentence in lowercase letters is: " ;
    streamin.getline(sentence,100);
    cout<< sentence <<endl;
    
    
    streamout.open("test2.txt");    
           
    cout<< " The sentence in uppercase letters is: " ;
    streamin.getline(sentence,100);
      for(i=0;sentence[i]!=0;i++)
         {   toupper(sentence[i]);
         }
    ofstream.streamin("test.txt");
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

this is where i have reached..

Ancient Dragon commented: Thanks for taking the time to read the rules and use code tags correctly :) +23

line 3: should be <fstream> (without the .h extension)

line 12: since on line 11 you used ifstream you can use ofstream for the output stream.

line 28: incorrect. should be this: sentence[i] = toupper(sentence[i]); delete line 30 because it does nothing but confuse everything. I suspect what you are attempting to do is write the converted string to the output file. streamout << sentence << "\n";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.