Error in Visual Studio

Asked

Viewed 130 times

3

EDIT: Problem solved, after changing much of the code, not only in the functions mentioned here, the error stopped occurring.

I’m getting this mistake and I have no idea what might be causing it, I’ve never seen it before. Any hint about the cause of the error?

inserir a descrição da imagem aqui

After clicking Break the code that appears is this:

_CRTIMP PFLS_GETVALUE_FUNCTION __cdecl __set_flsgetvalue()
{
#ifdef _M_IX86
    PFLS_GETVALUE_FUNCTION flsGetValue = FLS_GETVALUE;
    if (!flsGetValue)
    {
        flsGetValue = DecodePointer(gpFlsGetValue);
        TlsSetValue(__getvalueindex, flsGetValue);
    }
    return flsGetValue;
#else  /* _M_IX86 */
    return NULL;
#endif  /* _M_IX86 */
}

The error occurs when arriving at this part of the code:

void imprime_vertices(head* h)
{

    int i, n;
    n = (h[0]).grau;

    for(i = 1; i <=n; i++){
        printf("%d %d %d\n", h[i].vertice[0], h[i].vertice[1], h[i].vertice[2]);
    }
    printf("\n");
}
  • When the error occurs and you press "Break", what is the information in the call stack window (call stack)? It can give a good indication of where the error lies. If you have questions about the code in the indicated location, do not forget to edit the question to include it, otherwise it is very difficult for someone to help. :)

  • Updated. @Luizvieira

  • Ok. :) Sorry if the question seems too basic, but you came to debug its function imprime_vertices to see if (1) the pointer h is properly allocated and (2) the degree of the vertex is consistent with the number of edges? By the way, why do you print three values for each edge on the vertex? Without knowing its data structure, I would imagine that if they are fixed they should be two identifiers (of the current vertex and of the other to which the edge connects).

  • I will debug yes, the error is in Visual Studio itself, since compiling and running in the terminal the code runs normally.

  • I don’t think the error is "in Visual Studio". Maybe the error is happening and your program ends without you noticing. VS is only warning you because in it you run in debug mode. Take a look at the existing answer. She has an important tip related to what I was commenting on.

  • 4

    This question seems to be decontextualized because it is about a very specific author coding error, which will hardly be useful to other people in the community (at least in the current format of the question).

Show 1 more comment

1 answer

3

Using the i like Indice an array, this seems wrong

for(i = 1; i <=n; i++)
// h[0] nao acedido
// tentativa de aceder a h[n], que nao existe???

The arrays, in C, go from the Dice 0 to the Indian N-1. The canonical way of writing a cycle that traverses all elements of an array is

for (i = 0; i < n; i++)
  • Very well noted. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.