i2c adapter number verification


I am trying to connect the beaglebone to the MCP23016 I2C port expander. I am using eclipse environment and C++

According to this link (https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/i2c/dev-interface) the I2C adapter number is assigned dynamically and may change on re-boot.

Is this correct ?? The link also mentions i2cdetect must be used to get the correct adapter number.

How can I use i2cdetect tool in my c++ program to get the correct adapter number ??

i have studied derekmalloy’s video on the i2c based accelerometer, but I am note sure how the adapter detection is done…

Could anyone help me out please…