473,513 Members | 13,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STL jump to line

Hi. Is there any function like getline which loads specified line from
a text file? Something like getline(myfile, line, 10); where 10 means
10th line in the file.

Aug 6 '07 #1
4 1891
ra*******@gmail.com wrote:
Hi. Is there any function like getline which loads specified line from
a text file? Something like getline(myfile, line, 10); where 10 means
10th line in the file.
No. It's too easy to write using 'getline' and 'ignore' to bother
putting it in the library, methinks.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 6 '07 #2
On Aug 6, 4:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
raven....@gmail.com wrote:
Hi. Is there any function like getline which loads specified line from
a text file? Something like getline(myfile, line, 10); where 10 means
10th line in the file.

No. It's too easy to write using 'getline' and 'ignore' to bother
putting it in the library, methinks.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
So how to code it?

Aug 6 '07 #3
ra*******@gmail.com wrote:
On Aug 6, 4:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>raven....@gmail.com wrote:
>>Hi. Is there any function like getline which loads specified line
from a text file? Something like getline(myfile, line, 10); where
10 means 10th line in the file.

No. It's too easy to write using 'getline' and 'ignore' to bother
putting it in the library, methinks.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

So how to code it?
Something like

std::istream& skip_lines(std::istream& is, std::size_t n)
{
while (is && n--)
is.ignore(
std::numeric_limits<std::istream::streamsize>::max (),
'\n');
return is;
}

...
std::ifstream myfile; // and open it
if (skip_lines(myfile, 10))
getline(myfile, line);

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 6 '07 #4
In article <11**********************@k79g2000hse.googlegroups .com>,
ra*******@gmail.com says...
Hi. Is there any function like getline which loads specified line from
a text file? Something like getline(myfile, line, 10); where 10 means
10th line in the file.
No -- to do something like that, you'd need an index of the text file
telling where each line begins. You can do that, but it's not built in.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Aug 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3384
by: Sandy | last post by:
See line beginning with WHAT GOES HERE ..... Do Until ......................... Code .... .... If .............. Then WHAT GOES HERE TO JUMP TO THE END OF THE LOOP AND LOOP AGAIN End If...
1
2681
by: René | last post by:
Hello I'm developing a program in c# that uses a RichTextBox. Now i wonder, how can i jump to a specific line in the document that is shown in that richtextbox? /René
9
3855
by: paul c | last post by:
Apologies if I'm sending this to the wrong group. If so I'd be grateful if somebody could point me to the right one. I'm using microsoft visual c++ 6.0 compiler. My code is C, I just use the...
1
2251
by: Dave E | last post by:
Hi folks, I have a VB.Net application, currently being developed on my XP Pro 2002 SP2 box. It is pretty straightforward and accesses my local SQL2000 instance. Randomly I get the above error...
4
1998
by: robert d via AccessMonster.com | last post by:
When my app starts up, it creates a temporary database. This temp database is created from a 'model' database that is in the same folder as the application. Because there is a model, the creation...
9
4302
by: questions? | last post by:
I opened a file with fileptr=fopen(filaneme,"r"); I then use fgets(a_string, sizeof(a_string),fileptr); to read each line. How to jump over a prespecified number of lines without doing...
6
5015
by: Todd A. Anderson | last post by:
I have a function foo of which I need to get the address. The problem is that when you say "&foo" (or just foo for that matter), you get the address of this function's entry in a jump table and...
5
3475
by: Horacius ReX | last post by:
Hi, sorry but after looking for information, I still did not get how, when reading a text file in python, can one jump to a concrete line and then read the different data (separated by spaces). In...
6
5993
by: teddysnips | last post by:
I've been asked to take over maintenance of a database. The client has also requested that I split the database into Front End/Back End. I've just taken delivery of the code and I've run it and it...
1
2625
Fary4u
by: Fary4u | last post by:
Hi hope anybody sort this problem i've got -> progress bar which control with the coding & it's jumps into time line. what i would like to do -> on the same time it's jump into the particular...
0
7254
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
7373
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
7432
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
7519
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
5677
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,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.