fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. int idade = 0;
  6. printf("Hello! How old are you? ");
  7. scanf("%d\n", &idade);
  8. while (idade == 0) {
  9. printf("\nAge cannot be 0 nor be decimal. Re-enter your age: ");
  10. scanf("%d", &idade);
  11. }
  12. char nome[21];
  13. fgets(nome, 20, stdin);
  14. nome[strcspn(nome, "\n")] = 0;
  15. printf("\nHello %s, aged %d!\n", nome, idade);
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/320255/101
Success #stdin #stdout 0s 4352KB
stdin
20
josé da silva
stdout
Hello! How old are you? 
Hello josé da silva, aged 20!