#if defined(_WIN32) // количество цифр в INT_MAX #define MAX_TYPE 10 #elif defined(_WIN64) #define MAX_TYPE 19 #endif double Racially_Correct_Input(char a[]) //функция для ввода допустимых значений с клавиатуры { double c, num, z; int i = 0; int flagpoint = 0; //признак того, что точка есть в числе char str[MAX_TYPE + 2];//строка с числом while ((c = getch()) != 13 || i == 0) //ввод числа до нажатия enter { if (i > MAX_TYPE ) //проверка на домустимый размер числа (проверка при помощи INT_MAX есть на выходе) { for (i; i > 1; str[i--])//очистка экрана от введённого числа { printf("\b \b"); } printf("\b \b"); printf("Nedopustimii razmer!"); getch(); for (int j = 0; j < 20; j++) //очистка консоли от printf("Nedopustimii razmer!"); { printf("\b \b"); } if (a == "int") return Racially_Correct_Input("int");// если нужно НАТУРАЛЬНОЕ число if (a == "double") return Racially_Correct_Input("double");//всё остальное } if (isdigit(c) || (c == '-') && (i == 0) && a == "double" || a == "double" && (c == '.') && !flagpoint) //Если символ является цифрой или знаком /* || c == '.'*/) { if (c == '.') { flagpoint = 1; z = i; } //Если ввели точку, меняем флаг, обозначающий, что точка введена str[i++] = (char)c; putch(c); } else if (c == 8 && i > 0) // 8 - keys BACKSPACE { printf("\b \b"); // destructive backspace if (i - 1 == z) flagpoint = 0; str[i--] = (char)c; } else if (c == 27) //выход из программы и очистка памяти при помощи самопальной функции { Free(A); exit(1); } else if (c == 32 ) //рестарт программы { Free(A); menu(); } } str[i] = '\0'; //Сформированную строку заершаем признаком окончания строки num = atof(str); //Преобразуем строку в число с точкой if (atof(str) > INT_MAX) { printf("\nNedopustimii razmer!\n"); if (a == "int") return Racially_Correct_Input("int"); if (a == "double") return Racially_Correct_Input("double"); } return num; }
Standard input is empty
prog.cpp: In function 'double Racially_Correct_Input(char*)': prog.cpp:11:11: error: 'MAX_TYPE' was not declared in this scope char str[MAX_TYPE + 2];//строка с числом ^ prog.cpp:12:20: error: 'getch' was not declared in this scope while ((c = getch()) != 13 || i == 0) //ввод числа до нажатия enter ^ prog.cpp:16:19: error: 'str' was not declared in this scope for (i; i > 1; str[i--])//очистка экрана от введённого числа ^ prog.cpp:18:19: error: 'printf' was not declared in this scope printf("\b \b"); ^ prog.cpp:20:18: error: 'printf' was not declared in this scope printf("\b \b"); ^ prog.cpp:27:55: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] if (a == "int") return Racially_Correct_Input("int");// если нужно НАТУРАЛЬНОЕ число ^ prog.cpp:28:61: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] if (a == "double") return Racially_Correct_Input("double");//всё остальное ^ prog.cpp:30:16: error: 'isdigit' was not declared in this scope if (isdigit(c) || (c == '-') && (i == 0) && a == "double" || a == "double" && (c == '.') && !flagpoint) //Если символ является цифрой или знаком /* || c == '.'*/) ^ prog.cpp:35:5: error: 'str' was not declared in this scope str[i++] = (char)c; ^ prog.cpp:36:12: error: 'putch' was not declared in this scope putch(c); ^ prog.cpp:40:19: error: 'printf' was not declared in this scope printf("\b \b"); // destructive backspace ^ prog.cpp:42:5: error: 'str' was not declared in this scope str[i--] = (char)c; ^ prog.cpp:46:10: error: 'A' was not declared in this scope Free(A); ^ prog.cpp:46:11: error: 'Free' was not declared in this scope Free(A); ^ prog.cpp:47:11: error: 'exit' was not declared in this scope exit(1); ^ prog.cpp:51:10: error: 'A' was not declared in this scope Free(A); ^ prog.cpp:51:11: error: 'Free' was not declared in this scope Free(A); ^ prog.cpp:52:10: error: 'menu' was not declared in this scope menu(); ^ prog.cpp:55:2: error: 'str' was not declared in this scope str[i] = '\0'; //Сформированную строку заершаем признаком окончания строки ^ prog.cpp:57:16: error: 'atof' was not declared in this scope num = atof(str); //Преобразуем строку в число с точкой ^ prog.cpp:58:18: error: 'INT_MAX' was not declared in this scope if (atof(str) > INT_MAX) ^ prog.cpp:60:36: error: 'printf' was not declared in this scope printf("\nNedopustimii razmer!\n"); ^ prog.cpp:61:54: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] if (a == "int") return Racially_Correct_Input("int"); ^ prog.cpp:62:60: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] if (a == "double") return Racially_Correct_Input("double"); ^
Standard output is empty