“Variável de impressão bool em c” Respostas de código

Imprima bool c

// there is no way of pretty-print a boolean with printf
printf("%i", true);  // will print 1
printf("%i", false); // will print 0

// but we can create a macro
#define formatBool(b) ((b) ? "true" : "false")
printf("%s", formatBool(true));  // will print true
printf("%s", formatBool(false)); // will print false
Thoughtful Trout

Variável de impressão bool em c

#include <stdio.h>
#include <stdbool.h>
int main(){
  int o = true;
  printf("%i", o);
  /*
  Output
  1
  1 means true
  */
  int q = false;
  printf("%i", q);
  /*
  Output
  0
  0 means false
  */
}
Yucky Yak

Respostas semelhantes a “Variável de impressão bool em c”

Perguntas semelhantes a “Variável de impressão bool em c”

Mais respostas relacionadas para “Variável de impressão bool em c” em C

Procure respostas de código populares por idioma

Procurar outros idiomas de código