need small c++ help please

Discussion in 'Programming General' started by autoplatinum, Mar 12, 2011.

need small c++ help please
  1. Unread #1 - Mar 12, 2011 at 3:02 PM
  2. autoplatinum
    Joined:
    Sep 4, 2010
    Posts:
    51
    Referrals:
    0
    Sythe Gold:
    0

    autoplatinum Member
    Banned

    need small c++ help please

    Basically i am making a simple word processor in c++ and would like to be able have a function which opens a txt file and then edits it but i have no idea how to do that. Help would be much appreciated. Thanks
     
  3. Unread #2 - Mar 13, 2011 at 8:47 AM
  4. wackywamba
    Joined:
    Jul 14, 2005
    Posts:
    1,358
    Referrals:
    0
    Sythe Gold:
    1

    wackywamba Guru

    need small c++ help please

    Hey there :), what you will need to do is use an "ifstream" you will need to include the fstream

    ifstream filestream;
    filestream.open ("textfile.txt");

    That will create an ifstream that will open the textfile.txt (note: file must be in the same folder obviously)

    Then to read from it use:

    Code:
    while(!filestream.eof) //checks if the filestream has not reached its "eof" - end of file
            {
    	        getline(infile,STRING); //gets a string from the file similar to a buffered reader in java
            }
    	infile.close(); //always remember to close your any stream :)
    I sell java and c++ help my thread is in my sig if you're interested.
     
< Plzz Modify Code Game... | need a little help cant figure out how to use mouse events to zoom on an image >

Users viewing this thread
1 guest


 
 
Adblock breaks this site