CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    How to read ints from a text file

    for instance like:
    12 32 323 342
    12 3213 23 12
    and store them into a array


  2. #2
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: How to read ints from a text file

    Something like this:


    #include <fstream>
    using std::ifstream;

    int main()
    {
    char *filename = "in.txt";
    ifstream in(filename);

    int ar[1000];
    int i = 0;

    while (in)
    {
    in >> ar[i++];
    }

    return 0;
    }





    Please - rate answer if it helped you
    It gives me inspiration when I see myself in the top list =)

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    [email protected] | ICQ:57404554 | http://soukhov.com

    Member of Russian Software Developer Network http://rsdn.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

  3. #3
    Guest

    thank you

    thank you


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

Featured