ansible select inventory file to adhoc command

C++
# Use flag -i and the path to the inventory. 
ansible all -i=/etc/ansible/[your_inventory] -m ping
Source

Also in C++: