Part of my program displays a list of valid IDs, their pay, and a list of bad ids. Several of the values are.. empty I guess so they display as 0s. How can I keep that from happening?

Recommended Answers

All 5 Replies

How can I keep that from happening?

Fill them up with stuff.

Much as I'd love to that isn't an option. I just need them to not show up.

test the attributes before issuing a cout instruction, if != 0 then display, else move on to the next attribute.

Edit: Took out code because it wasn't really necessary.


And my brother in law said "It's printing 0's because you initialized them to 0, and you didn't set a value in goodEmpIds or totalPay for bad IDs. If goodEmpIds[ct] is zero then you know it's bad, and the ID would be in badEmpIds[ct] instead.".... but I can't seem to understand what he's saying :(

Thank you so much. You helped me solve my problem. After I posted that bit there I went and looked at it some more and did what you said. Tested with if(goodEmpId > 0) in the print method and it printed perfectly.

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.