Strange errors

This is the first c++ scripting i have ever done, but there was an error that i don't know how to fix.
The following error is:
-error LNK2019: unresolved external symbol _main referenced in function _tmainCRTStartup
-error LNK1120: 1 unresolved externals

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>
#include <stdlib.h>

void Console_test()
{
	char colour;
    std::cout << "Hello user" << ",/0" << "What is your favorite colour" << "green," << "blue/0" << "or red?/n";
	std::cin >> colour;
	switch (colour)
	{
	case 1: system("COLOR 2");
		break;
	case 2: system("COLOR 1");
		break;
	case 3: system("COLOR 4");
		break;
	default: system("COLOR F0");
		break;
	};
	if (colour == 1 && 2 && 3)
	{
		std::cout << "Voila" << "," << "The colour has been switched :D/n";
	};
};
You do not have main() function in your program.
Every program should contain int main() as this is the function which started at the program launch.
Tried but still happens, where should i put it exactly?
Last edited on
No. Main function in C++ has signature either
1
2
3
int main()
//or
int main(int argc, char** argv)
A few problems: As MiiNiPaa pointed out, you need an int main() { /*code here*/ } function where your code execution begins.
for example:
1
2
3
4
5
int main()
{
    Console_test();
    return 0;
}


___________________
Line 20:
if (colour == 1 && 2 && 3)
The && operator here isn't working in the way you want it to. 2 and 3 are treated as their own separate expressions. Also, I think you mean to use OR logic instead of AND, because you want that if-statement to execute if any of the options are true.

so basically:
if (colour == 1 || colour == 2 || colour == 3)
__________________
Line 7: The escape character for "newline" is '\n' not '/n'.
Last edited on
Oh thanks.
Topic archived. No new replies allowed.