0

I have an error... /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain' I can't understand why I have that error. Here is my program:

#include< iostream >
int n, m, a[101][101], viz[101];

using namespace std;

void DFS(int x)

{



int i;



viz[x]=1;

 for(i=1;i<=n;i++)

 if(a[x][i]==1 && viz[i]==0) DFS(i);

}

int Conex()

{int i;

DFS(1);

for(i=1; i<=n; i++)

if(viz[i]==0) return 0;

return 1;

}

what should I do?

  • 4
    All c++ programs need a `main` function. Sounds like you could use a [good C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver May 12 '20 at 20:13
  • 2
    Your linker is correct. There is not `int main()` in the code that is shown. Related: [https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main](https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main) – drescherjm May 12 '20 at 20:19

1 Answers1

0

You dont have a main function for this program, check the link https://en.cppreference.com/w/cpp/language/main_function.

Use either int main {
                       // do your stuff
                     return 0;
                     }
or           void main {
                         // do your stuff
                        }
user9559196
  • 157
  • 6