I'm a newbie in C.For a month or so i have started learning and a friend is giving me tips and homework.My newest homework is something like this:
I have a garaje with 3 floors,each with 10 parking spaces.Each hour cost 5$.Only the cars who have left pay.
The problem is that i have to read form a file i maid which contains 4 columns:nr of the floor,time spent in the garaje, entrence time and leaving time.
My task is to know at any time how much cash I've earnd an how many parking spaces i have free on each floor.
I made the file,I'm able to read from it but i don't know hot to point each column to it's respectiv data structure.
Any tips or guidance would be appreaciated.Sorry for the spelling.

Recommended Answers

All 2 Replies

I think i have to use malloc..but i'm not sure.

No malloc needed, but there are always ways you could use malloc, of course.

Think of a 2D table:

Floor space numbers
===================

[row 0 of the table] [1 = occupied, 0 = empty space]
   1  2  3  4  5  6  7  8  9  10  << element number

1  0  1  1  1  1  1  1  0  1   1  << data in row 0

[row 1 of the table]
   1  2  3  4  5  6  7  8  9  10
2  1  1  1  1  1  1  0  0  0  0   << data in row 1

[row 3 of the table] [1 = occupied, 0 = empty]
   1  2  3  4  5  6  7  8  9  10
3  0  1  0  1  1  0  0  1  1  1   << data in row 3

See if that helps. How much you've made so far would be a running sum you start every day, anew, and wouldn't probably go into this table.

To find how many spaces are empty, scan through the table, and count the 0's in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.