renix1

Apredendo sobre MACROS

Feb 29th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. //#error Isso gerarĂ¡ um erro
  4.  
  5. int main (void) {
  6.     //FUNC
  7.     void executa_arquivo(void);
  8.     //REST
  9.     #ifdef __cplusplus
  10.         printf("Voce esta usando C++\n");
  11.     #else
  12.         printf("Voce esta usando C\n");
  13.     #endif // __cplusplus
  14.     #ifdef __STDC__
  15.         printf("Voce esta usando um Compilador ANSI C\n");
  16.         printf("Executando %s na linha %d\n", __FILE__, __LINE__);
  17.         printf("Voce esta executando em %s as %s\n", __DATE__, __TIME__);
  18.     #else
  19.         printf("Voce nao esta usando um Compilar ANSI C, isso pode gerar erros\n");
  20.     #endif // __STDC__
  21.     executa_arquivo();
  22.     return(0);
  23. }
  24.  
  25. void executa_arquivo (void) {
  26.     int indice = 0;
  27.     for (; indice < 3; indice++) {
  28.         printf("Criando um arquivo...\n");
  29.     }
  30.     FILE *arquivo;
  31.     arquivo = fopen("status.txt", "w");
  32.     fprintf(arquivo, "O programa %s esta em fase de teste e foi executado em %s as %s\n", __FILE__, __DATE__, __TIME__);
  33.     fclose(arquivo);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment