In general, this will depend on your OS. There's no real standard API for this.
Assuming you're on linux, open and parse /proc/net/arp. The format is similar to that of the output from the arp command. Note that you must send a packet to the IP in question at least once recently in order to have it in the ARP table, and of course you won't get anything outside of your local segment.
Getting an IP into this cache is easy enough - just send a UDP packet to it on some unused port, for example - then poll until it shows up.
Another alternative would be to use a raw socket to craft and send your own arp packet, but that's much more complex :) If you do want to go down this route, study the source code for arping (page is down today, but the git repo is online), which might also give you a bit more portability by using platform-independent-ish libraries like libpcap (but requires root)