Thread: String/Data Manipulation

  1. #1
    Unregistered
    Guest

    String/Data Manipulation

    I have some data in the following format:

    gggg@ gggggggg gggggg ggggggggg
    trrehd@ dffdhghtr rggffrg nhgvhvgnhgyy
    po@ dkjfkdg gfdkjhjdkhf dgfgfffff ffff
    ppppppoppo@ dsgjhfdkhvc gfdkjhgkj kjhgkf

    Now I want to output the data that comes after the '@' for each line. Any help is much appreciated!

  2. #2
    Unregistered
    Guest
    Check out the getline command

  3. #3
    Unregistered
    Guest
    I'm using the Win API and because of that I can't use getline().

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    I assume the data are saved on a file and you are trying to read the data into memory.

    -----
    // std::getline(sourcefile, string);

    // this should return the index of "@"
    // int index = string.find('@');

    // for (int i = ++index; i < string.size(); ++i)
    // cout << string[i]
    -----

    The code above is a concept. You should modify it to fit your need and to optimize your program.

    Kuphryn

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    66
    windows API and STL are not mutually exclusive. You can use getline just fine.

  6. #6
    Unregistered
    Guest
    I've been unable to get the getline() function to work. Any suggestions?

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    show us the line that you tried using getline().

  8. #8
    Unregistered
    Guest
    I've tried the following:
    Code:
    getline()
    std::getline()
    ifstream::getline()
    : error C2065: 'getline' : undeclared identifier

  9. #9
    Registered User
    Join Date
    May 2002
    Posts
    317
    What header files have you included. Sounds to me like you are leaving one out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. message box LPCWSTR manipulation and keyword question
    By stanlvw in forum Windows Programming
    Replies: 11
    Last Post: 05-27-2008, 12:36 PM
  2. Bit Manipulation Questions
    By CPPNewbie in forum C++ Programming
    Replies: 7
    Last Post: 08-12-2003, 02:17 PM
  3. MFC and String Manipulation
    By Strut in forum Windows Programming
    Replies: 2
    Last Post: 09-17-2002, 05:29 AM
  4. string manipulation
    By ubershatten in forum C++ Programming
    Replies: 1
    Last Post: 07-25-2002, 10:37 PM
  5. File manipulation
    By Shadow in forum C Programming
    Replies: 1
    Last Post: 04-23-2002, 08:07 AM