Do functions in VCS have to be in a certain order?

  1. 5 weeks ago

    AKBAB

    Dec 13 United Kingdom 66618Z

    Hi, when compiling my program, I've found that functions called in VCS don't run unless declared above the line that calls it (i.e the whole function has to be written above the main() code). Is there a way to declare functions at the top of the program while writing them out somewhere lower down?

  2. Barin

    Dec 13 Arizona
    Edited 5 weeks ago by Barin

    @AKBAB Hi, when compiling my program, I've found that functions called in VCS don't run unless declared above the line that calls it (i.e the whole function has to be written above the main() code). Is there a way to declare functions at the top of the program while writing them out somewhere lower down?

    void thisIsAFunctionThatDoesStuff(); //Declare function
    
    int main() {
      thisIsAFunctionThatDoesStuff(); //Call function
      return 0;
    }
    
    void thisIsAFunctionThatDoesStuff() { //Define function
      // Do stuff
    }
 

or Sign Up to reply!