-1

I just started to learn c++ and I wanted to show an arry in promt but i get this weird error

this is my code:

#include "stdafx.h"
#include "conio.h"
#include <iostream>
using namespace std;

void _show(char a[10][10])
{
    int i,j;
    for(i=0;i<10;i++)
        for(j=0;j<10;j++)
            cout<<a[i][j];
}
void _main(int argc, _TCHAR* argv[])
{
    char a[10][10];
    int i,j;
    for(i=0;i<10;i++)
        for(j=0;j<10;j++)
            a[i][j]=0;
    _show(a);
}

and this is the error:

Error 1 error LNK2019: unresolved external symbol _main referenced in function

Error 2 error LNK1120: 1 unresolved externals

user2302416
  • 87
  • 2
  • 11
  • 3
    You want `_tmain`, not `_main`. And unless you're creating some project type that requires VisualC++ extensions, I'd lose the `#include ` (and turn off pre-compiled headers); and replace `void _tmain(int argc, _TCHAR* argv[])` with `int main(int argc, char* argv[])` – Praetorian Jul 29 '13 at 19:34
  • 2
    You should find another source for your learning. You are using plenty of non-c++ constructs here. – juanchopanza Jul 29 '13 at 19:34
  • More on the [main function here](http://en.wikipedia.org/wiki/Main_function). Note that the `_TCHAR` thing is not standard C++, but is standard for a certain C++ implementation. Also, see [this list of books](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – juanchopanza Jul 29 '13 at 19:38
  • can you give me a good menual to learn from? – user2302416 Jul 29 '13 at 19:38
  • 2
    You are also accessing out of bounds. Needs to to <10 rather than <11 – David Heffernan Jul 29 '13 at 19:40
  • @user2302416 As first, I would start learning classic C over C++. – Martin Perry Jul 29 '13 at 19:41

2 Answers2

4

Your program is missing "main" function (which is used as entry point from OS). This function MUST have name: int main(int argc, char * argv[]) (for classic console based application)

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
Martin Perry
  • 9,232
  • 8
  • 46
  • 114
0

Don't use underscores here is an explanation why as they are reserved

main function should be declared as

int main(int argc, char *argv[])
Community
  • 1
  • 1
A. H.
  • 942
  • 10
  • 20