FWLIW, I'd put only the initial M | F and final enumeration into IF statements. And then I'd put the largest IF ... THEN ... ELSE into a SWITCH ... CASE instead: it's easier to read.
while(!EOF) { /* read file into array */ if (M && ){ switch(etc) do whatever break; [...] switch(etc) count++ else if switch(etc) else switch(etc) count++ } Just my 0.02c worth - don't spend it all at once - we _do_ have a financial ongoing crisis. ;) Wesley Parish Quoting [EMAIL PROTECTED]: > I hope people don't mind me posting these here, let me know if you do > and > I'll find a more appropriate geek list to post them. > > The C program I'm working on at the moment is taking a list from a data > file and populating an array to either be outputted either to screen, > file > or printer. the foo.dat file is like this: > > F 26 5 > F 64 4 > F 29 2 > M 12 3 > M 40 1 > ...snip... > > So I need to populate (using count++) a two-dimensional array based on > whether the first column is M or F the second column is within a range > and > whether the thrid column is either 1,2,3,4or5 > > This is the part that's doing my head in, I could do it using a very > convoluted if-else-if loop which would end up giving me a massive and > hard > to maintain piece of code > > ie: > > if line == (F && < 25) && 1) > then count++ to array[0][0] > > else if line == (F && < 25) && 2) > then count++ to array[1][0] > > etc, > > etc, > > etc, > > (code won't compile - made it more human readable for mostly my > sake...) > > doing it this way I would end up with 25 if-else-if statements. is there > a > way to take the && 1) section read the number from the third coloumn > from > the foo.dat file and minus one from it? This would give me the x axis > of > the array - or am I barking completly up the wrong tree? > > Or is there a better way to do this? any pointers would be appreciated. > > Kerry > > ps, I hope I'm making some kind of sense with all of this..... > "Sharpened hands are happy hands. "Brim the tinfall with mirthful bands" - A Deepness in the Sky, Vernor Vinge "I me. Shape middled me. I would come out into hot!" I from the spicy that day was overcasked mockingly - it's a symbol of the other horizon. - emacs : meta x dissociated-press