Error library stdafx.h [closed]

2

Does anyone know why it makes a mistake in this library and how to fix it?

This is declared in the codeblocks header:

#include "stdafx.h"
#include <windows.h>

#define TAM_PILHA 2
#define NUM_ENTRA 5

void empilha(int *pilha, int *topo, int valor)
{
if (*topo < TAM_PILHA)
{
    pilha[*topo] = valor;
    (*topo)++;
}
else
{
    printf("Pilha Cheia\n");
}
}

int desempilha(int *pilha, int *topo)
{
if (*topo > 0)
{
    (*topo)--;
    return pilha[*topo];
}
else
{
    printf("Pilha Vazia\n");
}
}

int main()
{
int pilha_par[TAM_PILHA], pilha_impar[TAM_PILHA], topo_par = 0, topo_impar = 0;
int i = 0, num_do_usuario = 0;
for (i = 0; i < NUM_ENTRA; i++)
{
    printf("\nEntre com um numero: ");
    scanf("%d", &num_do_usuario);

    if ((num_do_usuario % 2) == 0)
    {
        empilha(pilha_par, &topo_par, num_do_usuario);
    }
    else
    {
        empilha(pilha_impar, &topo_impar, num_do_usuario);
    }

}

printf("\n\nNumeros pares sao: ");
while (topo_par > 0)
{
    printf("%d ", desempilha(pilha_par, &topo_par));
}

printf("\n\nNumeros impares sao: ");
while (topo_impar > 0)
{
    printf("%d ", desempilha(pilha_impar, &topo_impar));
}

printf("\n\n");

system("pause");
return 0;
}

Error appears:

fatal error: stdafx.h: No such file or directory|
    
asked by anonymous 13.03.2017 / 12:54

1 answer

2

stdafx.h is used by the Visual Studio implementation of precompiled headers. In many cases this can be avoided, especially if your project is small and with few dependencies.

To resolve you can copy the stdafx.h file from the Visual Studio project folder to the project codeblocks folder and try to compile.

I did the test here, removing:

#include "stdafx.h"
#include <windows.h>

and including #include <stdio.h> , worked normally.

If you still can not solve your problem, you have this Code :: Blocks forum about your doubt.

    
13.03.2017 / 19:34