VEX V5 Coding Sections

Okay, so I’m coding for my team this year for Tower Takeover, but I am confused about something.

There are four sections in the V5 competition template (Correct me if I’m wrong):

    `void pre_auton( void )`
`void autonomous( void )`
`void usercontrol( void )`
`int main()`

On the website help.vex, it said:

  • The competition template has three sections that correspond to the three phases of a competition match: robot setup, autonomous, and driver control.

I have major questions about this.

First, I counted four sections, so why does the website say three?

Second of all, I THINK that the 'int main` tag is the one that doesn’t correspond with one of the competition phases. If it doesn’t have robot setup, driver control, or autonomous in it, then what does it contain?

Also, if I’m incorrect about 'int main` being the one that doesn’t correspond with the competition template, which tag is it, and what goes in it if it doesn’t correspond?

Also, ONE last thing. Can I please have some examples of what would go in the tag that has nothing to do with the competition?

Sorry if this question was a bit lengthy :sweat_smile: . I just really need to understand this.

Thank you for your time! :smile:

1 Like

int main() is where the program starts, without it the program wouldn’t run.

I recommend that you learn C++ before coding in vex.

Here are some resources to learn C++ https://www.learncpp.com and this playlist

1 Like

int main() is the entrypoint of the program. It is where everything starts executing.
IIRC, In the template, main first calls void pre_auton(), where you can put code that initializes or calibrates your robot.
int main() also registers competition callbacks, basically saying "when competition control is set to drivercontrol, run this function named void usercontrol(), and when its set to autonomous, run this function named void autonomous()".
If int main() is empty, I suppose VCS already assumes the callbacks (using weak linking) so basically you don’t have to do anything.
Hope this helps.

2 Likes

Thanks, will do! :smile:

Thank you for the info! It was super helpful! :smile: