Проблемы при развертывании приложения после обновления с Glassfish3 до Glassfish4

scanf не потребляет новую линию и, следовательно, является естественным врагом fgets. Не складывайте их без хорошего взлома. Оба этих параметра будут работать:

// Option 1 - eat the newline
scanf("%d", &a);
getchar(); // reads the newline character

// Option 2 - use fgets, then scan what was read
char tmp[50];
fgets(tmp, 50, stdin);
sscanf(tmp, "%d", &a);
// note that you might have read too many characters at this point and
// must interprete them, too
0
задан Anthony Vinay 1 March 2019 в 12:28
поделиться