2
Does anyone know why there’s a mistake in this library and how to fix it?
This is stated 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|
Places which error appears.
– Taisbevalle
Enter your complete code, this error may have several causes.
stdafx.h
is a header precompiled from the visual studio, there are cases that do not need it, sometimes it is necessary to includewindows.h
. I can’t say without seeing the full code.– Taisbevalle
I’ve already put the entire code in there for analysis.
– André
This header is generated by VS, if you open it you will see that it contains other statements of headers, serves only as "shortcut", can add its contents directly in your project.
– bruno101