***int main() & me***

Team,

When I write a program using int main() has worked well for my needs. As my program grows though - I want to move to other areas of the program. How would I do this

1
2
3
4
5
6
7
8
9
10
  int main() { 
std::cout << "blah";
//If a condition is met jump to secondary.
return main();
}

Int secondary ()
{
Std::Cout << "hola"
/*Stay in this function until condition met then return to main()*/
Hello shycas2008,

A quick example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

int secondary();  // <---Function prototype

int main()
{
	std::cout << "blah";
	//If a condition is met jump to secondary.

	if (condition is true)
	{
		secondary();  // <--- Function call
	}

	return 0;
}

int secondary()  // <--- Lowercase i.
{
	std::cout << "\nhola";  // <--- Lowercase letters. Missing ;
		/*Stay in this function until condition met then return to main()*/

        return int;
}


Hope that helps,

Andy

Edit.
Last edited on
Topic archived. No new replies allowed.