My program has SFML so I am not going to post that code but here is simple version of what I mean
#include <iostream>
using namespace std;
int main()
{
void function();
{
cout << "Hello world!" << endl;
}
return 0;
}
The program will say Hello World
but I want it to only run when i call the function later on
How do I stop that?
I see the problem, as previously noted by Paradigm Shifter and Washu, you're not coding a "function inside main".
What you are doing is declaring a function:
void function(); // Notice that ";", it marks the end of the function declaration
and then adding "Hello World!" to cout.
{
cout << "Hello World!" << endl;
}
the { and } are just block separators, that you can use to limit scopes, between some other things.
So the function and the { cout } aren't related by any means.