Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 24th, 2005, 10:14 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
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
  #2 (permalink)  
Old February 25th, 2005, 03:40 AM
Authorized User
 
Join Date: Oct 2004
Location: Fayetteville, AR, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to C@uark
Default

Well what I would do is have a loop to read a line in from file, have a nested loop to tokenize the line using strtok(string.h header)with a delimiter of whitespace. check the token for one of the words that you wish to delete. If it is not a word that you wish to delete save to your new file(with append option), if it is a word that you wish to delete continue through the loop to the next token.
Reply With Quote
  #3 (permalink)  
Old November 23rd, 2007, 07:25 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

program does'nt work
Reply With Quote




Similar Threads
Thread Thread Starter Forum Replies Last Post
File handling vijayma VB How-To 3 June 7th, 2006 01:30 AM
C# Code for Handling Speaker Volumes ramk_1978 C# 2 March 16th, 2006 08:40 AM
FILE HANDLING yojeiram_n1 C++ Programming 2 March 13th, 2006 02:57 PM
c++ file handling. amahja56 C++ Programming 2 March 23rd, 2005 07:13 PM
FILE HANDLING sanchita ADO.NET 8 November 8th, 2004 12:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.