Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-16-2008, 03:47 PM   #1
LQ Newbie
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
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.


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

until the end of Coordinates


is this too complicated or tedious for me to ask?

love from Manchester

Old 04-16-2008, 06:12 PM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
Old 04-16-2008, 06:51 PM   #3
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
And monitor for end-of-file.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
HDD partition lost. xandros DVD + me = lost data lein Linux - General 18 05-22-2007 05:47 AM
Bind have lost some zone in named.conf & lost db file achilles Linux - Enterprise 0 04-19-2007 06:22 AM
Howto recover lost and formatted data on lost partitions. Sören Schneider Member Success Stories 2 04-05-2006 06:38 AM
power lost from cable modem, interface lost a10392 Linux - Networking 4 11-16-2004 09:01 AM
C++ templates + linked lists... lost.. very lost.. exodist Programming 2 05-12-2004 11:04 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration