I believe that by pinging devices on the network you mean ICMP, see also icmp(7).
The obvious way of understanding how to do that on Linux is to take advantage that it is made of free software and to get the source code related to the ping
command (on Debian & Ubuntu in the inetutils-ping package). Also, you could strace
some ping
command (to understand the relevant syscalls, see also syscalls(2) and the Advanced Linux Programming book).
I strongly suggest to take the habit of compiling and studying and improving free software.
You could also use the libping library; you'll probably need root privileges.
For tips about C & C++ development on Linux see this answer.