detect network device when using libpcap in ubuntu

Hi all,
I use libpcap to write a program to detect network device in Ubuntu but not sucess. The result is no suitable device found. How many reasons are there for that? please help? The code i used is the main user page.