Adblock breaks this site

need small c++ help please

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

  1. autoplatinum

    autoplatinum Member
    Banned

    Joined:
    Sep 4, 2010
    Posts:
    51
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  2. wackywamba

    wackywamba Guru

    Joined:
    Jul 14, 2005
    Posts:
    1,358
    Referrals:
    0
    Sythe Gold:
    1
    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 >


 
 
Adblock breaks this site