#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    2
    Rep Power
    0

    Builder C++ getline


    Hi all,
    I have file in format:
    | field_1 | field_2 |......|up to field_15|
    | name_1| phone_1|......|..................|
    | name_2| phone_2|......|..................|
    | name_3| phone_3|......|..................|
    .
    .
    .

    and I want pump this file into StringGrid or sth like that.
    and I suppose that I should use to getline() and I don't know how to use it

    How pump this file into StringGrid or I don't know???, I want have
    nice application with data in fileds

    cheers,
    Pablo

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. Updated
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    124
    Rep Power
    12
    Create a StringList, load file with StringList->LoadFromFile("filename")
    Then process each line and insert into your grid...
    for (int i = 0; i<=StringList->Count;i++) {
    //process the string StringList->Strings[i] and fill your grid
    }
    Happy coding!

    Comments on this post

    • JimmyGosling agrees
  4. #3
  5. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    What he said should work, but for general info on using getline:

    #include <fstream.h>

    In your code:
    char data[20][80];
    fstream fin;
    fin.open ("Myfile.txt");
    for(int i=0; i<20 && !fin.eof(); i++)
    fin.getline(data[i], 80);

    fin.close() //don't forget this!
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn

IMN logo majestic logo threadwatch logo seochat tools logo