Resetting file pointer position

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thefer
    New Member
    • May 2013
    • 1

    Resetting file pointer position

    it will search the whole file once then i cant get it to reset without restart the program.

    Code:
    cin >> paycode;
    
    while(paycode!=0)
    {
      while(!infile.eof())
      {
        infile >> search;
        infile.ignore(1);
        infile >> salary;
    
        if (search == paycode)
        {
          cout << salary;
        }
      }
    Last edited by Banfa; May 10 '13, 08:50 AM. Reason: Added code tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You need to be doing something along the lines of calling

    Code:
    infile.clear();
    infile.seekg(0, infile.beg);

    Comment

    Working...