Não incluir stdlib.h não produz nenhum erro de compilador!
Espero que esta seja uma pergunta muito simples. A seguir está o C pgm (test.c) que tenho.
#include <stdio.h>
//#include <stdlib.h>
int main (int argc, char *argv[]) {
int intValue = atoi("1");
double doubleValue = atof("2");
fprintf(stdout,"The intValue is %d and the doubleValue is %g\n", intValue, doubleValue);
return 0;
}
Observe que estou usando atoi () e atof () do stdlib.h, mas não incluo esse arquivo de cabeçalho. Eu compilo o pgm (gcc test.c) e não recebo nenhum erro do compilador!
Eu corro o pgm (./a.out) e aqui está a saída, que está errada.
The intValue is 1 and the doubleValue is 0
Agora incluo o stdlib.h (removendo os comentários antes do #include) e recompile-o e execute-o novamente. Desta vez, recebo a saída correta:
The intValue is 1 and the doubleValue is 2
Como o compilador não se queixou de não incluir o stdlib.h e ainda me deixou usar as funções atoi (), atof ()?
Minhas informações do gcc:
$ gcc --version
gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-27)
Quaisquer pensamentos apreciados!