Can't get do while loop working (SOLVED)
Code:
#include <stdlib.h>
#include <stdio.h>
#define MAX_STRING_LENGTH 1
int main(void) {
/* Variáveis. {{{ */
char estado_civil;
char resp[MAX_STRING_LENGTH];
int idade;
int casad = 0; /* Casado(a). */
int solt = 0; /* Solteiro(a). */
int viuv = 0; /* Viúvo(a). */
int sep = 0; /* Desquitado ou separado. }}} */
do {
printf("Idade?\n");
scanf("%d", &idade);
printf("%d.\n", idade); getchar();
printf("Etado civíl ?\n"
"C, casado(a); S, solteiro(a); V, viúvo(a); D, desquitado(a):\n");
estado_civil = getchar();
switch (estado_civil) { /* {{{ */
case 'C': case 'c':
casad++;
break;
case 'S': case 's':
solt++;
break;
case 'V': case 'v':
viuv++;
break;
case 'D': case 'd':
sep++;
break;
default:
printf("Caractere inválido.\n");
break;
} /* }}} */
printf("Mais uma pessoa? (s/n)\n");
scanf("%s", resp);
/* scanf("%1c", resp); */
/* getchar(); */
/* resp = getchar(); */
} while (strcmp(resp, "s") != 0);
printf("C = %d, S = %d, V = %d, D = %d.\n", casad, solt, viuv, sep);
return 0;
}
/*
* vim: foldmethod=marker foldmarker={{{,}}}
*/
No matter the resp is "s" or not, the do while loop always stops..