В каком случае окончанием ввода строки будет служить нажатие клавиши Enter?
(Отметьте один правильный вариант ответа.)
Варианты ответа
#include <stdio.h>#include <conio.h>#define N 10int main(){ int i=0; char arr[N] = ""; printf("Last Name: "); do { arr[i] = _getche(); i++; } while ((i<N) && (arr[i]!="Enter")); 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; } (Верный ответ)
#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; }