CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    14

    simple input problem

    Thank you
    Last edited by yamahammer342; May 4th, 2009 at 08:28 PM.

  2. #2
    Join Date
    Dec 2008
    Posts
    56

    Re: simple input problem

    I find this hard to believe! The following code works fine:
    Code:
    #include <fstream>
    #include <string>
    #include <iostream>
    
    int main()
    {
      std::fstream file("data.dat", std::ios::in);
    
      std::string name, days;
      int crn, start, end;
    
      file >> name >> crn >> start >> end >> days;
    
      std::cout << "name  = " << name  << "\n"
                << "days  = " << days  << "\n"
                << "crn   = " << crn   << "\n"
                << "start = " << start << "\n"
                << "end   = " << end   << std::endl;
    }
    The "data.dat" contains the same data as you posted.

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