0
Where is the error?
No errors are shown when I compile and execute, simply nothing is shown, anyone can identify the error? #include <stdio.h> main () { float salario; char genero, fim = 's'; int cont, idade; for (cont=0;fim=='n'; cont++) { printf("Digite a idade: "); scanf("%i", &idade); printf("Digite o genero: "); scanf("%c", &genero); printf("Digite o salário: "); scanf("%f", &salario); printf("Deseja continuar? s/n"); scanf("%c", &fim); } } Obs.: It's not complete, I'll finish when I find the error. kk Thanks!
3 Réponses
+ 2
Your for loop is never entered. fim == 'n' is false as it is set to 's'.
+ 1
I found the problem.
I solved it using a space before "%c", for example:
scanf(" %c", genero);
0
Thank you ChaoticDawg, but I have another problem haha
"Digite a idade: 20
Digite o genero:
Digite o salário: "
When I run it, the program doesn't ask for the character (s/n) and jump to "Digite o salário: ", I tryed to use another comand "fim = getche()", but I think this comand can be used just with "conio.h", and I'm using Linux.
I'm brazillian, my english isn't so good, sorry haha