newbie lost... kinda like paradise lost but less demon
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.
newbie lost... kinda like paradise lost but less demon
um hiya,
new round these parts, not sure if i'm breaking any forum rules posting here, so i'll just go ahead and ask my question and trust that if i'm in the wrong place then a moderator shall rollok me.
right
we'll im (trying) to write a C++ script within the GEANT4 framework,
its pretty much the same apart from renaming stuff with a G4 infront and a whole load of librarys
my problem is:
(bear in mind that im not very good at programming to begin with)
Need to read in a file (Coordinates)
Coordinates is comprised of three columns of size N, columns are separated by tab.
occasionally within this file there is a discontinuity and there is a blank line at a random place.
i wish to read these lines (column1 column2 column3) into an array of size [3][n]. until the blank line
perform OPERATION on this array and then out put "results for set"
then resume sweeping and recording the data from Coordinates until the next blank line.
repeat ad inifinitum throughout Coordinates adding the outpout for each set into "results for set" withoutover writing
I don't know anything about GEANT4 but I have a little familiarity with C++, and programming in general.
I would say that what you want to do is to build up you program slowly.
Get the function to read in the file line by line. For each line increment a counter so at the end you can say how many lines were read, just to confirm that has worked.
Then for each line check if it is blank or not, you can either display the number of blank lines or the line number that is blank.
Now you should have a situation where you can read in the file and know which lines need processing and which are blank.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.