Good day! I wrote a program, but it does not start, there are not even any error messages. Can you help? Actually, the program itself:
#include <iostream> #include <windows.h> #include <fstream> using namespace std; int keybard_enter(int matrix[3][7]) { fstream file1; file1.open("C:\\SOURCE\\Project\\matrix.txt", ios::out); int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 7; j++) { cin >> matrix[i][j]; file1 << matrix[i][j] << " "; } } cout << endl; file1.close(); return matrix[3][7];} int file_enter(int matrix[3][7]) { int i, j; fstream file1; file1.open("C:\\SOURCE\\Project\\matrix.txt", ios::in); cout << "Массив:" << endl; for (i = 0; i < 3; i++) { for (j = 0; j < 7; j++) { file1 >> matrix[i][j]; cout << matrix[i][j] << " "; } cout<<endl; } file1.close(); return matrix[3][7];} void out_matrix_file(int matrix[3][7]) { int i, j; fstream file1; file1.open("C:\\SOURCE\\Project\\end_matrix.txt", ios::out); file1 << "Конечная матрица:"; file1 << "\r"; for (i = 0; i < 3; i++) { file1 << "\n"; for (j = 0; j < 7; j++) { file1 << matrix[i][j] << " "; } file1 << "\r";} file1.close(); cout << "\nФайл успешно создан!\n\n"; } void rewrite_matrix (int matrix[3][7]) {char answer2; cout << "1. Найти положительные числа 2. Найти отрицательные числа 3. Найти нулевые числа " << endl; cin>>answer_2; switch (answer2) {case '1': int n=0; for(int i=0;i< 3;i++){ for(int j=0;j< 6;j++){ if(matrix[i][j]>0) {n=n+1;}}} fstream file1; file1.open("C:\\SOURCE\\qwerty.dot", ios::out); file1<<"Положительных чисел "<<n; file1.close(); break; case '2': int m=0; for(int i=0;i< 3;i++){ for(int j=0;j< 6;j++){ if(matrix[i][j]>0) m=m+1;}}} fstream file1; file1.open("C:\\SOURCE\\qwerty.dot", ios::out); file1<<"Отрицательных чисел "<<m; file1.close(); break; case '3': int k=0; for( int i=0;i< 3;i++){ for(int j=0;j< 6;j++){ if(matrix[i][j]>0) {k=k+1;}}} fstream file1; file1.open("C:\\SOURCE\\qwerty.dot", ios::out); file1<<"Нулевых чисел "<<k; file1.close(); break; default: cout << "Выберите 1, 2, 3!";break; } int main() { int matrix[3][7]; char answer1, answer2; setlocale(LC_ALL, "russian"); cout << "\n Подсчёт элементов.\n" << endl; inception: cout << "\nПрограмма подсчёта.\n" << endl; cout << "1. Загрузить массив из файла.\n2. Ввести вручную.\n" << endl; cin>>answer1; switch (answer1) { case '1': file_enter(matrix); break; case '2': keybard_enter(matrix); break; default: cout << "Выберите 1 или 2!"; goto inception; break; } cout << endl; for (;;) { cout << "\n1. Изменить элемент массива.\ \n2. Записать конечный массив в файл.\ \n3. Выйти из программы.\n" << endl; cin>>answer2; if (answer2 == '3') {break;} switch (answer2) { case '1': rewrite_matrix(matrix); break; case '2': out_matrix_file(matrix); break; default: cout << "\nВыберите 1, 2 или 4!\n"; break; } } return 0; }
answer_2but it is not declared anywhere. here's one of the compilation errors. I can not believe that the compiler did not give anything at all. - cybrex