473,325 Members | 2,608 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,325 software developers and data experts.

read a line from textfile

friendjin
How can I read every line from the existed file.
eg.
the content of textfile:
serialnumber = " 50";
serialfile path = "C:\\doc\\";
errorfile path = "C:\\doc\\d\\";

I want to read "50" from the first line to SeNo, read ""C:\\doc\\ "from the second line to SePath, read "C:\\doc\\d\\" ifrom the third line to ErPath.

any idea how it can be achieved. thanks
Feb 15 '07 #1
8 6261
open file

Loop untill EOF
begin
read line
search in the line for '='
Now copy the remaining string in to Destination.
end

close file

How can I read every line from the existed file.
eg.
the content of textfile:
serialnumber = " 50";
serialfile path = "C:\\doc\\";
errorfile path = "C:\\doc\\d\\";

I want to read "50" from the first line to SeNo, read ""C:\\doc\\ "from the second line to SePath, read "C:\\doc\\d\\" ifrom the third line to ErPath.

any idea how it can be achieved. thanks
Feb 16 '07 #2
sicarie
4,677 Expert Mod 4TB
open file

Loop untill EOF
begin
read line
search in the line for '='
Now copy the remaining string in to Destination.
end

close file
And if you need help on the functions that go with kvbreddy's algorithm, I find this site to be very good with examples (I also like how they have the other functions in the library of the function (still with me?) you are looking up, off to the left of the screen).
Feb 16 '07 #3
open file

Loop untill EOF
begin
read line
search in the line for '='
Now copy the remaining string in to Destination.
end

close file
Hi kvbreddy;
Thanks. the problem is I could not workout readline command, and how can I do a search.
I would so appreciate if you could write this part of code for me.
Feb 21 '07 #4
sicarie
4,677 Expert Mod 4TB
Hi kvbreddy;
Thanks. the problem is I could not workout readline command, and how can I do a search.
I would so appreciate if you could write this part of code for me.
Sorry, but we can't do that. This is in C, right? What error messages did you get when you tried readline?
Feb 21 '07 #5
Sorry, but we can't do that. This is in C, right? What error messages did you get when you tried readline?
Sorry about that I did not mention it. it is in VC++.
error is identifier was not found.
Feb 21 '07 #6
sicarie
4,677 Expert Mod 4TB
Sorry about that I did not mention it. it is in VC++.
error is identifier was not found.
Can you post the segment where you use readline() in your code?

Is this written in C#? C and C# have readline functions - I don't believe C++ does... (Please anyone correct me if I'm wrong.)
Feb 21 '07 #7
Can you post the segment where you use readline() in your code?

Is this written in C#? C and C# have readline functions - I don't believe C++ does... (Please anyone correct me if I'm wrong.)

I actually have already worked out, but I chose another method by using strstr.

but I do want to konw how readline works in C++.

any ideas..thanks
Feb 22 '07 #8
sicarie
4,677 Expert Mod 4TB
I actually have already worked out, but I chose another method by using strstr.

but I do want to konw how readline works in C++.

any ideas..thanks
That was what was confusing me. To my knowledge, readline is not in C++. (Though I could be wrong - its happened several times recently)

I personally prefer getline.
Feb 22 '07 #9

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

Similar topics

1
by: dmiller23462 | last post by:
Hi again guys.... This is my first source of help, by far the best ASP intellectual collective....Thanks in advance for any assistance...Anyway.... The forms I'm still working on (finishing...
2
by: Tim Bücker | last post by:
Hello. Is there a way to read a specified line in a textfile? Something like TextReader.ReadTextLine(4); It seems very odd to use reader.ReadLine(); reader.ReadLine(); reader.ReadLine();...
6
by: eight02645999 | last post by:
hi wish to ask a qns on strip i wish to strip all spaces in front of a line (in text file) f = open("textfile","rU") while (1): line = f.readline().strip() if line == '': break print line
9
by: Justme | last post by:
Novice programmer needs help with using fgets to read and ignore the first two lines of a file. I've gone thru the previous posting regarding fgets, but none of them seems to help my situation. I...
6
by: Kinbote | last post by:
Hi, I'm trying to make a function that opens a file, reads it in line by line, puts each line into an malloc'd array, and returns the array. I suspect I'm going about it in an atypical fashion, as...
1
by: saytri | last post by:
Hi i'm a student studying java (i'm still a beginner). i have a project were i have to do a quiz with a set of questions. So i think that i have to type the questions in a textfile for example in...
0
by: Snoze | last post by:
Hello, I'm trying to make an application with C# that writes and reads some lines of a text file, but I want to read one specific line and save the text in a string variable. And the inverse...
6
by: Per Juul Larsen | last post by:
Hi. My Textfile looks like this Variable 1 Variable 2 Variable 3 Variable 4 On opening the application it will read the textfile, and assign each line of variable to at textfield in VB and...
3
by: Raymond Chiu | last post by:
Dear all, Now I have the simple task to read text file line by line into database (SQL Server 2000). If the text file is divided into different fields according to the number of characters,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.