-2

So this is my code,

//Precompiled Libaries
#include <iostream>
#include <string>
#include <string.h>
#include <Windows.h>
#include <conio.h>
#include <process.h>
#include <time.h>
#include <stdlib.h>
#include <ctime>
#include <cstdlib>
#include <stdio.h>
#include <fstream>

//Program To Run From
using namespace std;

int intNumber1;
string strName;

void Menu(void){
cout << "Please Select Your Choice " << strName << "!";
Sleep(2000);
}

void Name(void){
cout << "Please Enter Your Name" << endl;
cin >> strName;

Menu();
}

void Main(void){

system("COLOR C");

Name();
}

its just simple stuff, probably wrong as just learnt in college, but these are the errors when building,

1>------ Build started: Project: Revision Application, Configuration: Debug Win32 ------ 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>C:\Users------\Desktop\Revision Application\Debug\Revision Application.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Then when debugging,

Unable to start program 'C:\Users------\Desktop\Revision Application\Debug\Revision Application.exe'.

The system cannot find the file specified.

im probably being silly but i cant find a fix anywhere :( please help!

R33D3Y
  • 32
  • 7
  • Your app must build in order to debug, and the errors you included clearly indicate that didn't happen: **Build: 0 succeeded, 1 failed**. How can you debug an application you can't create? They provide descriptions of errors on purpose, because *the words they contain have meaning and provide information*. You should learn now to actually *read those words*. – Ken White Jan 17 '15 at 02:13

1 Answers1

2

C++ is case-sensitive, and the entry function is called main, not Main. Also, it must return int, not void. Replace

void Main(void){

with

int main() {

to make your code compile and link. Then, once you built the .exe, you will be able to use the debugger on it.

Note that only in main, you do not explicitly have to return a value from it even though the return type is not void. main returns 0 by default. By convention, this indicates to the surrounding shell that the program ended without error.

Wintermute
  • 42,983
  • 5
  • 77
  • 80
  • Well done (spotted). I'm going to dupe it out anyway, if you don't mind. That question hasn't been researched and asked that well. Vote for dupes, as you know or find them please. That will help alot improving the site. – πάντα ῥεῖ Jan 17 '15 at 02:22
  • Thank you so much, ive been trying to figure this out for over a month and my teacher couldn't help me with this easier, this way others can also find what they want. Again, thank you! – R33D3Y Jan 17 '15 at 10:07