Thread: Input/Output to external files, I NEED HELP!!

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    1

    Input/Output to external files, I NEED HELP!!

    Please help me!

    I am trying to make a program that searches through a .txt file for email adresses. The best way to separate them I think would be to use something that takes the word from a everything before an @ symbol until a space, coma, semicolon, or greater than or less than symbol, and everything after the @ symbol until 3 letters after the first period that is found.(example

    <[email protected]>, [email protected]; [email protected] "Wef Aeff",

    Emails are organized differently, so i think that the way i described is a fairly fullproof method.

    I have a medium understanding of C++, but im not that good.

    I want the program to search throught the .txt file, find emails, and delete duplicate emails that are found later on in the .txt file.

    Will someone PLEASE give me detailed instructions of how to do it, or simply write the program for me and send the .cpp and the .exe file to me?

    I really need help with this one...

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Unfortunately your method is not so full proof. You see... when you open a file, it gets spit out into a buffer that you can then pull from. If you were to read from that buffer until you get to a @ sign, then everything before that would be discarded. Your best bet in doing this would be to open the file, read in a single word and store it into a string, use the std::string's find() function to look for a @ sign. If you find it, then check to make sure it ends with a URL extention. If it does, it's an email.

    Code:
    ifstream inFile("emailsandsuch.txt");
    string currWord;
    vector<string> emails;
    
    while(inFile >> currWord)
        if (currWord.find('@', 0) != string::npos && currWord.find('.', currWord.size() - 4) != string::npos)
           emails.push_back(currWord);
    
    inFile.close();
    Or something similar. Lastly, never ask someone to write a program for you. If they want to give you code examples they will, but asking them to write it and send it to you is just asking for trouble.
    Last edited by SlyMaelstrom; 02-24-2006 at 04:24 AM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    or simply write the program for me and send the .cpp and the .exe file to me?
    Send me $2,000 to my Paypal account and you got it.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Convince me this isn't just another way of harvesting email addresses for spamming....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Help with input/output files
    By aldin176 in forum C++ Programming
    Replies: 5
    Last Post: 11-06-2006, 09:04 AM
  3. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  4. Book's code: Problematic
    By RoD in forum Game Programming
    Replies: 14
    Last Post: 01-21-2003, 09:08 AM
  5. Unresolved external symbols in OGL
    By Shadow12345 in forum Game Programming
    Replies: 4
    Last Post: 08-04-2002, 09:46 PM