View Single Post
  #1 (permalink)  
Old February 24th, 2005, 10:14 AM
amahja56 amahja56 is offline
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default here is my code c++ file handling


# include <conio.h>
# include <fstream.h>



 main()
{
    ifstream file ("Text.text");
    ofstream nfile("NewText.text");
    char row[1000];
    char string[25];

    int i;


    if(!file)
    {
             cout<<"cannot open file"<<endl;
             return 1;
    }

    for(i=1;i<=7;i++)
    {
            file.getline(row,1000);

             cout<<row<<"\n";




    if(!nfile)
    {
             cout<<"cannot open file"<<endl;
             return 1;
    }


    }

    for(i=1;i<=7;i++)
    {
        if(string =="for" || string =="every")
        {
            string == " ";
            file.getline(row,1000);
            cout<<row<<"\n";
        }
    }


    file.close();
    return 0;
}


this is the code that only shows the contents of the original file.

Reply With Quote