OK, so you don't actually need to know the number of semaphores available on your system, you just need to know the value of a particular one. I totally misread you, which is why it's good to be specific when asking a question so people have some idea what you want.
In any case, I have not written semaphore code in a looong time but I think you can do what you want using semctl with the GETVAL cmd argument. Please see "man semctl" for more details. Note that this is if you're using the System V style semaphore API. If you're using POSIX semaphores the correct function is sem_getvalue (the description is in the man page for sem_init).based on the fact you were looking for sem_getcount (note the underscore), I'm guessing you're using POSIX semaphores and so sem_getvalue is the function you seek.