473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Resetting file pointer position

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

Expand|Select|Wrap|Line Numbers
  1. cin >> paycode;
  2.  
  3. while(paycode!=0)
  4. {
  5.   while(!infile.eof())
  6.   {
  7.     infile >> search;
  8.     infile.ignore(1);
  9.     infile >> salary;
  10.  
  11.     if (search == paycode)
  12.     {
  13.       cout << salary;
  14.     }
  15.   }
  16.  
May 10 '13 #1
1 1501
Banfa
9,065 Expert Mod 8TB
You need to be doing something along the lines of calling

Expand|Select|Wrap|Line Numbers
  1. infile.clear();
  2. infile.seekg(0, infile.beg);
May 10 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: W. Van Hooste | last post by:
Hello, I'm writing a program to display somme values as nice X graphics for a special purpose. Under here is part of my main code and part of the code to gather the sample data. the sample data...
21
by: deepak | last post by:
hi folks I have a pointer to a file. If i increment the pointer, where will it point. I could not find the problem in the FAQs. Thanks in advance Deepak garg
3
by: Don Pasquale | last post by:
The following function intends to delete "numberoflines" lines from a text file, named "s" (string pointer) and pointed to by file pointer "fp", starting from line "line". Now, the function...
2
by: Kevin Zhou | last post by:
I have a file that contains 22 lines, each line has two float separated by a space. I want to store those float data into a two-dimensional array which size I want the program to determine at run...
1
by: Lisa | last post by:
Using C# .NET, I want to create a BinaryWriter to read Int32 data from a file, but I don't see any facility to set the file pointer to a specific point within the file. Thanks for any help. ...
1
by: Arif | last post by:
Following are my text file(IndxItms.txt) contents: --------------------------------------------------- 0000 0 0002 52 0020 260 0045 312 0051 364 0087 416
3
by: TomHL | last post by:
this code set the color that I want only on the first pixel. I have an X & Y values of the pixel that I want to change. How do I change the pointer's position according to my X & Y values that I...
9
by: Abhishek | last post by:
Hello everybody, I am reading a file into a char array. Because of which we cannot give array size in GBs of data. Is there a technique through which i can cast a file pointer to char pointer...
1
by: prybrr04 | last post by:
Hello All, I wanted came here to get some advice on reading an input file where I will have to ignore some of the text. Here is the sample text file: SIZE: 4 ROWS, 4 COLUMNS SCORE: 0 0 ----...
5
by: jefer | last post by:
I would like to write a value on keydown (i'm going to use external triger) at mouse pointer position outside visual basic application (to a acces database cell or excel cell). ans suggestion how to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.