Hey yall, so this is one of the last things I should do for my project and I can't seem to come up with a good idea for it so I thought I would bring it here. I have to display a "lab" of "computers" and show which ones are empty. Below is the code I have so far, and it outputs it in a big list. I just wanted to see if there was some way to get it to print with 5 stations to a line.
So instead of
#1: empty
#2: empty
#3: empty
#4: empty
#5: empty
#6: empty
#7: 13432
it is
#1: empty #2: empty #3: empty #4: empty #5: empty
#6: empty #7: 13432 ........
The main issue I'm having is trying to wrap my head around the 2d arrays and such, so any help would be greatly appreciated. Thanks!
Printing some data with n items per line doesn't really have much to do with 2d arrays. If you count how many items have been printed, then using the mod operator (%) will indicate whether you need to output a newline or not. As per AbstractionAnon's code above L11-12.
Thank you AbstractionAnon, your idea worked, I also had to remove the "\n" from my lines in the main loop but it works exactly as expected. What I meant by having problems meant I am still new to this stuff and this array project I have been working on has been very difficult. I knew it didn't have much to do with them, but I am very surprised the answer was just some modulus and that was it. Thank yall again.