Using int main() instead of void setup() and void loop()

I appreciate all of the insight. I have looked into the 2560 datasheet kind of heavily, and have utilized it for the entire semester thus far. This is the first time we have used communication and have not really learned anything about it. Page 246 of the Mega 2560 datasheet kind of lays out how to use I2C communication with conventional C code, but it is the information that is getting stored in TWDR that is kind of throwing me for a loop, and how to check what is in there. When looking at arduino.h all I see in there is them actually creating the functions for loop and setup, and I understand that setup is just being run one time, which is why I created a function for it and ran it once in main, and use the while loop to continuously run the code that was in the void loop. We have always used int main() and it appears to me that is how it should be gone about.

Thankfully I am an EE and this is my last coding based class at all. We are required to take two C/C++ classes and this micro controller class, but other than that there is no coding required for us. I have no desire whatsoever to do embedded programming or any programming for that manner besides simple matlab coding. I have done a couple internships in design, circuit analysis, etc. and plan to stick with that route.

In the twi.h and the wire.h I see the registers they are calling and what bits they are assigning in some of the registers for the Arduino's, so it it somewhat clear. The main confusion is how to just get the data from the VL53L0X. I understand we should be initializing the SCL and SDA lines, initializing the I2C by setting the prescalers correctly and getting the clock frequency by utilizing the I2C clock equation, then starting I2C using the start condition, wait for the end of a transmission, checking for the flag, loading the address (I believe 0x52 for write and 0x53 for read for this sensor), and waiting until the flag goes down to check for the end of the transmission. Then we must write the data, have a read acknowledgment, and then continue sending one until there is an nack, and then stop the transmission. Somewhere in there some data should be stored in TWDR, but I am not entirely sure how to get it, or if it is done correctly. I can't press forward without getting the int main function to work correctly before I start working on the I2C portion though.

Thanks btw!