This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have an array with given string that has two fields. I want to check the data in the field one and print data in filed two. So my array has following elements:-
And the output i desire is:-
CINSTALLDIR CM CT PJ RM RX SV TM
INSTALLDIR CT PJ TM
MINSTALLDIR CM RX SV
So what i did till now is this as below, I am not able to apply the proper logic. Could you please guide me what i am doing wrong? or some other approach.
are you writing all this code at once, and only then compiling/running/testing?
Do you have a plan?
the WORST way to write software is to write your whole program in one go. Plan out exactly how it should work. For example, if I wanted to read a file and print every line that has my name in it to the screen and save the other lines to a new file, i may start with this plan:
reading through this, I see an immediate problem...line 8 says 'write to a new file' but i don't know anything about any other file here. I'd go back and revise this pseudo-code. I'd probably spend more time coming up with this than anything else on my project.
then, and this is the MOST important part...i'd write as little code as I could before i compile and test the heck out of it. my first go is always nothing more than writing a main method that prints "i'm in main". once that works, I add a single piece. I'd do nothing more than the file open on the input file...and print a success or fail. compile and test.
then i'd try reading each line of the file, and printing it tot he screen. compile and test.
Then I'd try testing each line for 'fred' and print 'true' or 'false' for each line. compile and test.
then I'd try only printing the lines with 'fred' - compile and test.