>>I've already got two main
Programs can only have one main(). Delete one of the two you have.
Create another function and move the code you posted in main into that function. Then change main to just call that function. The code I posted is just an example of what your program should look like when you are done. foo() is just a generic name that means anything -- don't use it in your program but name it something else.