ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The basic idea is that I have a text file with lines of data.
The text file will read lines like: fNameone
ele
ele
ele
lee
lee
lee
lee
eel
fNametwo
ele
ele
ele
lee
lee
lee
lee
eel
eel
eel
eel
eel
eel
it will continue on many different names, it will know when a new name is reached by the first character being f. each time an f line is hit, then a counter variable c needs to increase by 1 to keep track of how many names and assign the name, excluding the f to name(c) until the next f line is hit, then it will count the number of items (ele's, lee's, eel's) contained by each name and assign them to a variable (ele(c), lee(c), eel(c) respectively.)
not sure this will make sense, and if it doesn't please let me know and i will try to explain it in a different way.
Seriously, what do you think this is here? Read the forum rules. We are not going to do youor homework for you. It won't help you either - you will not understand it if you cannot do it yourself.
We will help point you in the right direction, but you have to have a go first and ask specific questions. If you have no clue how to write a program in C++ - no idea even where to start, then you need to talk to your course tutor because you have not learned anything.
I will do your homework if you buy me one years worth of beer. You deliver first.
P.S. That is quite a lot of beer, and I have expensive tastes.
this isn't homework, it's just a minor piece of a project i am trying to make for a friend.. but i'm still new to c++ and don't really know much of the textfile related stuff.
Seriously, what do you think this is here? Read the forum rules. We are not going to do youor homework for you. It won't help you either - you will not understand it if you cannot do it yourself.
We will help point you in the right direction, but you have to have a go first and ask specific questions. If you have no clue how to write a program in C++ - no idea even where to start, then you need to talk to your course tutor because you have not learned anything.
how about this.
text file contains:
fSectionone
ele
lee
eel
fSectiontwo
ele
lee
eel
i need to know how to pull each line from the text file, and what function finds the first character of the string to determine if it is an f line.
This sort of task is really much easier in awk or Perl.
For example, if I understand your description properly, this Perl program will do what you want:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.