Какая программа реализует посимвольный ввод строки до тех пор, пока не будет нажата клавиша Enter, и последующий вывод введенной строки?
(Отметьте один правильный вариант ответа.)
Варианты ответа
#include <stdio.h>#include <conio.h>#define N 10int main(){ int i=0; char arr[N] = ""; printf("Last Name: "); while (i<N) { arr[i] = _getche(); if (arr[i]==13) break; i++; }; printf("\nYou have entered Last Name: %s", arr); return 0; }
#include <stdio.h>#include <conio.h>#define N 10int main(){ int i=0; char arr[N] = ""; printf("Last Name: "); while ((i<N) && (arr[i]!=13)) { arr[i] = _getche(); i++; }; printf("\nYou have entered Last Name: %s", arr); return 0; }
#include <stdio.h>#include <conio.h>#define N 10int main(){ int i=0; char arr[N] = ""; printf("Last Name: "); while (i<N) { arr[i] = _getche(); if (arr[i]==13) { arr[i] = '\0'; break; } i++; }; printf("\nYou have entered Last Name: %s", arr); return 0; } (Верный ответ)