Jump to content

[Resolvido] Erro: Stack overflow


polska

Recommended Posts

Boas pessoal, tentei correr um pequeno prog (não acabado) que estava a fazer, e deu-me os seguintes erros:

First-chance exception at 0x00b618c7 in B_ArranhaCeus.exe: 0xC00000FD: Stack overflow.

Unhandled exception at 0x00b618c7 in B_ArranhaCeus.exe: 0xC00000FD: Stack overflow.

Eu tentei num projecto novo e não resultou.. No meu código penso não haver nenhum erro de sintaxe..

code:

#include <stdio.h>

int main()
{
int N;
int torres[100][3], mapa[1000][1000] = {-1};
int edificios_visiveis = 0;
bool pintou;

scanf( "%d", &N );

for( int i=0; i<N; i++ )
{
 scanf( "%d %d %d", &torres[i][0], &torres[i][1], &torres[i][2] );
 pintou = false;
 for( int j=0; j<=torres[i][2]; j++ )
 {
  for( int k=torres[i][0]; k<=torres[i][1]; k++ )
  {
if( mapa[j][k] == -1 )
{
 mapa[j][k] = i;
 pintou = true;
}
  }
 }

 if( pintou )
  edificios_visiveis++;

}

return 0;

}

EDIT: Resolvido 😄

Edited by polska

Corrige um sábio e ele mais sábio ficará. Corrige um ignorante e um inimigo ganharás.

Link to comment
Share on other sites

Se estiveres a falar de C++ não há problema. O bool não existe em C a não ser que o definas ou incluas uma biblioteca.

Edited by KTachyon

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

É de C99, penso eu.

EDIT:

The C language did not have a boolean type until the C99 version of the standard. In C99 the boolean type has been added as _Bool. Additionally, a new header stdbool.h has been added for compatibility reasons.[/b'] This header allows programmers to use boolean types in the same way as in the C++ language. The missing identifiers are defined as macros: bool is defined as _Bool, true as 1, false as 0. Additionally, __bool_true_false_are_defined is defined as 1.
Edited by KTachyon

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

não vejo esse include ....

Ve 7.16 na definicao da linguagem C publicada em 1999 ou 7.18 na definicao de 2011 (ambos sao PDFs).

Edited by pmg

What have you tried?

Não respondo a dúvidas por PM

A minha bola de cristal está para compor; deve ficar pronta para a semana.

Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!

Link to comment
Share on other sites

mapa[1000][1000] = {-1};
...
if( mapa[j][k] == -1 )

Olha lá para estas duas linhas de código. Parece-te que mapa está inicializado com as dimensões correctas?

Se queres inicializar as posições todas a -1, tenta o memset.

Eu depois dei conta desse erro...

Esta corrigido ;D

Corrige um sábio e ele mais sábio ficará. Corrige um ignorante e um inimigo ganharás.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.