Results 1 to 3 of 3

Thread: Weird File I/O question

  1. #1
    Guest

    Post

    Ok, i want to find out if a file contain this string on the first line...

    ~~~blah blah blah~~~

    (Any thing can be on the next lines)

    And if it does delete it from the file, and make the line after that line the first line.

    Any ideas?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Hre is the code to find the string in the first line but for making it the first line i am not sure how.
    Code:
    #include <iostream.h>
    #include <string>
    #include <fstream>
    using namespace std;
    
    int main(int argc, char* argv[])
    {
    	ifstream ifile("c:\\textfile.txt");
    	string text;
    		getline(ifile,text);
    		int pos = text.find ("~~~blah blah blah~~~",0); //if pos != -1 then string found
    		cout<<pos<<endl;
    		
    	return 0;
    }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Guest
    if you are using namespace std you can't include .h on iostream either...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width