-
But I need this data to be represented in a grid of rows and columns. Vacant spaces should be marked as '-' , while taken spaces should be 'O'. Program must prompt user to enter row and column , and check whether space is vacant , if it is vacant , the user can enter new entry. I want it to look something like this :
Section 1
1 2 3 4 5 6 7 8 9 10
1 - - - - - - - - - -
2 - - - - - - - - - -
3 - - O - - - O - - -
4 - - - - - - - - - -
5 - - - - - - - - - -
6 - - - - - O - - - -
7 - - - - - - - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
10- - - - - - - - - -
Now this has to be repeated for each 5 sections.
-
So change your print function - it's not that hard if you've got this far.
-
Indeed! This is simple compared to the stuff you already did.
You already have the loops right:
Code:
for (i = 0; i < 10; i++) // go through each row
{
for (k = 0; k < 10; k++) // for each row, go through each column
{
So in here you just want to print the char isFree. So don't use %s, use %c for a char.
That'll print the chars in a long string. Getting it into a grid is easy - just print a newline in the outer loop. Then mess with the spacing until you're happy.
-
haha you just pin-pointed my problem. I dont' know where I need to print the isFree char :p
-
How can I go about relating each entry in the array to an '-' or 'O' in the grid , so that each '-' or 'O' represents a record ? How can the grid can then be printed ?