При каких значениях размерности n символьного массива и строки, на которую указывает указатель ptr, в результате выполнения приведенной программы возникнет ошибка? #include <stdio.h>#include <conio.h>#include <stdlib.h>#include <string.h>int main(void) { int n, m; char *ptr; printf("\nEnter a dimention of character array: "); scanf_s("%d", &n); _flushall(); ptr = (char *)malloc((n+1)*sizeof(char)); if (!ptr) { printf("\nERROR! Out of memmory (error in malloc() function). Press any key..."); _getch(); exit(1); } printf("Enter a character array (not more than %d characters): ", n); gets_s(ptr, n+1); m = strlen(ptr); strcat_s(ptr, m+2, "!"); printf("\nStart line and character \"%c\": %s", '!', ptr); free (ptr); printf("\n\nPress any key: "); _getch(); return 0; }
(Отметьте один правильный вариант ответа.)
Варианты ответа
n = 4, *ptr = "test"(Верный ответ)
n = 5, *ptr = "test"
n = 40, *ptr = "test"