Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.77/13: Рейтинг темы: голосов - 13, средняя оценка - 4.77
0 / 0 / 1
Регистрация: 27.12.2013
Сообщений: 19
1

access violation reading location

29.12.2013, 01:08. Показов 2375. Ответов 2
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
access violation reading location такая проблема если вести информацию про двух и больше студентов помогите пожалуйста очень срочно надо
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <conio.h>
 
using namespace std;
 
struct faculty
{
    char name[10];
};
 
struct course
{
    char name[10];
};
 
struct group
{
    char name[10];
};
 
 
struct student // студент
{
    char fio[20];   // name
    int facultyID;  // number in the array of faculties
    int courseID;   // номер в масиве факультетов
    int groupID;    // number in the array groups
    int rating[20]; // an array of ratings
};
 
int input(student* astudent, faculty* afaculty, int* f, course* acourse, group* agroup)
{
    int c=0; // counter courses
    int g=0; // counter groups
    int s=0; // counter students
    int r=0; // mileage ratings
 
    char answer_faculty, answer_course, answer_group,answer_student,answer_rating; //answers to the continued cycle
    do {
        cout << "faculty name:"<<endl; // enter the name of the faculty
        cin >> afaculty[*f].name;
 
        do {
            cout << "course name:"<<endl; // enter the name of the course
            cin >> acourse[c].name;
 
            int g=0;
            do {
                cout << "group name:"<<endl; // enter the name of the group
                cin >> agroup[g].name;
 
                do {
                    cout << "student name:"<<endl; //enter the name of the student
                    cin >> astudent[s].fio;
                    astudent[s].facultyID = *f; //number in an array of faculties
                    astudent[s].courseID = c; // number in an array of courses
                    astudent[s].groupID = g; // number in the array groups
 
                    int r=0; // mileage ratings
                    do {
                        cout << "rating:"<<endl; //introduce evaluation
                        cin >> astudent[s].rating[r];
                        if (astudent[s].rating[r]>0 && astudent[s].rating[r]<=5){ //ratings must be from 1 to 5
                            r++;
                            cout << "any rating else: (y/n)"<<endl; // request for continued input ratings
                            cin >> answer_rating;
                        }
                        else { // if invalid input, please repeat
                            answer_rating = 'y';
                            cout << "please enter rating from 1 to 5:"<<endl;
                        }
                    }
                    while(answer_rating=='y'); // check out of the loop
 
                    s++;
                    cout << "any student else: (y/n)"<<endl; // prompted to continue entering students
                    cin >> answer_student;
                }
                while(answer_student=='y'); // check out of the loop
 
                g++;
                cout << "any group else: (y/n)"<<endl; // request for continued group input
                cin >> answer_group;
            }
            while(answer_group=='y'); // check out of the loop
 
            c++;
            cout << "any course else: (y/n)"<<endl; // prompted to continue entering courses
            cin >> answer_course;
        }
        while(answer_course=='y'); // check out of the loop
 
        *f++;
        cout << "any faculty else: (y/n)"<<endl; // prompted to continue entering the faculties
        cin >> answer_faculty;
    }
    while(answer_faculty=='y'); // check out of the loop
 
    return (s); // return quantity of student, quantity of faculty is saved in the variable f
}
 
//names of students who have two or more deuces per session at the Faculty of IOT and remove them;
void student_exception(student* astudent, int s, faculty* afaculty, int f)
{ 
    for (int i=0;i<s;i++) { // bust students
        if (strcmp(afaculty[astudent[i].facultyID].name, "IOT")==0) { // found only students ІОТ
            int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // determine the size of the array count
            int count2 = 0; // number twos
            for (int j=0; j<count; j++){
                if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce plyusuem
                    count2++;
                }
            }
            if (count2>=2)
                cout << "Exclude a student: " << astudent[i].fio << endl; // finding makes student output
        }
    }
}
 
//faculty that 1 course has the highest number of excellent;
void excellent_faculty(student* astudent, int s, faculty* afaculty, int f, course* acourse)
{
    int facultresult[20]; // array for recording number excellent student by faculties
        for (int i=0; i<f; i++) facultresult[i]=-1; //initialize it -1
    int flag; // flag honors
    for (int i=0;i<s;i++) { // iterate students
        if (strcmp(acourse[astudent[i].courseID].name, "1")==0) { // Students find only 1 year
            int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
            flag = 1; //honors - check
            for (int j=0; j<count; j++){ // bust estimates
                if (astudent[i].rating[j]!=5 && astudent[i].rating[j]>0){ // search standouts
                    flag = 0; // if not honors, reset the flag honors
                }
            }
            if (flag==1) // add the desired array Faculty
                facultresult[astudent[i].facultyID]++;
        }
    }
    int maxfacul = -1; // number of honors
    int faculnum= -1; // number in an array of faculties
    for (int i=0; i<f; i++){
        if (facultresult[i]>maxfacul){ // if more honors
            maxfacul=facultresult[i]; // save their number
            faculnum = i; // save a room in an array of faculties
        }
    }
    if (faculnum == -1) // if not found honors
        cout << "Excellent student not found" << endl;
    else if (maxfacul>=0)
        cout << "excellent_faculty: " << afaculty[faculnum].name << endl; // derive the name of the faculty with the highest honors
}
 
void student_exception_course(student* astudent, int s, int f, course* acourse)
{
    int courseexception[20]; // number of exceptions for courses
    for (int i=0; i<f; i++) courseexception[i]=-1; // bybwbfkbpbhetv vfccbd -1
    for (int i=0;i<s;i++) { // sorted of students
        int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
 
        int count2 = 0; // number of honors
        for (int j=0; j<count; j++){
            if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce, plus
                count2++;
            }
        }
        if (count2>=2)
            courseexception[astudent[i].facultyID]++; //if two deuces student excluded - plus course
    }
    int maxcurs = -1; // the maximum number of excluded students on the course
    int maxcursnum = -1; // number in an array of courses
    for (int i=0; i<f; i++){
        if (courseexception[i]>maxcurs){ // excluded if more
            maxcurs=courseexception[i]; // keep the number of
            maxcursnum = i; // store the number course
        }
    }
    if (maxcurs == -1) // if not excluded
        cout << "Faculty not found" << endl;
    else if (maxcurs>=0)
        cout << "max student exception course: " << acourse[maxcursnum].name << endl; // derive the name of the course with the maximum number of exceptions
}
 
void main(void) 
{
    faculty afaculty[100];                  
    course acourse[100];
    group agroup[100];
    student astudent[100];
 
    int s=0; // counter students
    int f,t; //counter faculties
    f = 0;
    cout << "Create an array of structures. Each structure consists of the following elements: faculty, course, group, names of students test scores. "<< endl;
    cout << "Implement queries by identifying: \n1) the names of students who have two or more deuces per session at the Faculty of BCI and remove them, "<< endl;
    cout << "2) faculty, a freshman who has the most number of excellent and \n3) the course at which the greatest excluded number of students. "<< endl;
    s = input(astudent, afaculty, &f, acourse, agroup);
    student_exception(astudent, s, afaculty, f); //names of students who have two or more deuces per session at the Faculty of IOT and remove them;
    excellent_faculty(astudent, s, afaculty, f, acourse); //faculty that a freshman has the largest number of nouns;
    student_exception_course(astudent, s, f, acourse); //course at which the greatest number of students excluded.
    system ("pause");
}
Миниатюры
access violation reading location  
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
29.12.2013, 01:08
Ответы с готовыми решениями:

Access violation reading location
Помогите пожалуйста! Создаю программу, которая ведет учет данных. В бинарный dat-файл записываются...

Access violation reading location
добрый вечер , что может означать ошибка ? &quot;Exception thrown at 0x00B427CD in...

Access violation reading location
Уважаемые знатоки, подскажите пожалуйста в чем проблема или хотя бы типовые причины возникновения,...

ошибка Access violation reading location 0x00000066
Ошибка : Unhandled exception at 0x100e14cf (msvcr100d.dll) in 3.4.exe: 0xC0000005: Access violation...

2
DU
1500 / 1146 / 165
Регистрация: 05.12.2011
Сообщений: 2,279
29.12.2013, 02:12 2
могу посоветовать осваивать дебаг в студии. он там очень и очень хорош.
вот на картинки видно, что свалилось в строчке
facultresult[astudent[i].facultyID]++;
так же на картинке видно, что
astudent[i].facultyID == -858993460

если все так и есть на самом деле - то это выход за пределы массива.
astudent[i].facultyID - не инициализированна. почему - хз. поведение проги зависит от того, что вы там
вводили. я честно попробовал что-то повводить не особо вдаваясь в то, что ввожу. получил
бесконечный цикл.
так что помогите себе сами: разберитесь с дебагом в студии или исходники дайте, где
проблема воспроизводится сама, чтобы не надо было что-то вводить ну или в крайнем
случае для интузиастов точную последовательность ввода.
0
0 / 0 / 1
Регистрация: 27.12.2013
Сообщений: 19
29.12.2013, 02:44  [ТС] 3
DU, могу дать код где глобальные переменные там все работает нужно переделать чтоб не было глобальных переменных помогите пожалуйста заранее благодарен глобальные переменные подписал
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <conio.h>
 
using namespace std;
 
struct faculty
{
    char name[10];
};
 
struct course
{
    char name[10];
};
 
struct group
{
    char name[10];
};
 
struct student // студент
{
    char fio[20]; //name
    int facultyID; // number in the array of faculties
    int courseID;//номер в масиве факультетов
    int groupID;// number in the array groups
    int rating[20];// an array of ratings
};
 
 
 
int f=0; //counter faculties                //////////////Глобальные переменные///////////////
int c=0; // counter courses
int g=0; // counter groups
int s=0; // counter students
int r=0; // mileage ratings
faculty afaculty[100];
course acourse[100];
group agroup[100];
student astudent[100];
void input(){
    char answer_faculty, answer_course, answer_group,answer_student,answer_rating; //answers to the continued cycle
    do {
        cout << "faculty name:"<<endl; // enter the name of the faculty
        cin >> afaculty[f].name;
 
        do {
            cout << "course name:"<<endl; // enter the name of the course
            cin >> acourse[c].name;
 
            int g=0;
            do {
                cout << "group name:"<<endl; // enter the name of the group
                cin >> agroup[g].name;
 
                do {
                    cout << "student name:"<<endl; //enter the name of the student
                    cin >> astudent[s].fio;
                    astudent[s].facultyID = f; //number in an array of faculties
                    astudent[s].courseID = c; // number in an array of courses
                    astudent[s].groupID = g; // number in the array groups
 
                    int r=0; // mileage ratings
                    do {
                        cout << "rating:"<<endl; //introduce evaluation
                        cin >> astudent[s].rating[r];
                        if (astudent[s].rating[r]>0 && astudent[s].rating[r]<=5){ //ratings must be from 1 to 5
                            r++;
                            cout << "any rating else: (y/n)"<<endl; // request for continued input ratings
                            cin >> answer_rating;
                        }
                        else { // if invalid input, please repeat
                            answer_rating = 'y';
                            cout << "please enter rating from 1 to 5:"<<endl;
                        }
                    }
                    while(answer_rating=='y'); // check out of the loop
 
                    s++;
                    cout << "any student else: (y/n)"<<endl; // prompted to continue entering students
                    cin >> answer_student;
                }
                while(answer_student=='y'); // check out of the loop
 
                g++;
                cout << "any group else: (y/n)"<<endl; // request for continued group input
                cin >> answer_group;
            }
            while(answer_group=='y'); // check out of the loop
 
            c++;
            cout << "any course else: (y/n)"<<endl; // prompted to continue entering courses
            cin >> answer_course;
        }
        while(answer_course=='y'); // check out of the loop
 
        f++;
        cout << "any faculty else: (y/n)"<<endl; // prompted to continue entering the faculties
        cin >> answer_faculty;
    }
    while(answer_faculty=='y'); // check out of the loop
}
 
void student_exception(){ //names of students who have two or more deuces per session at the Faculty of IOT and remove them;
    for (int i=0;i<s;i++) { // bust students
        if (strcmp(afaculty[astudent[i].facultyID].name, "IOT")==0) { // found only students ІОТ
            int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // determine the size of the array count
            int count2 = 0; // number twos
            for (int j=0; j<count; j++){
                if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce plyusuem
                    count2++;
                }
            }
            if (count2>=2)
                cout << "Exclude a student: " << astudent[i].fio << endl; // finding makes student output
        }
    }
}
 
void excellent_faculty(){ //faculty that 1 course has the highest number of excellent;
    int facultresult[20]; // array for recording number excellent
    27.12.13    
        student by faculties
        for (int i=0; i<f; i++) facultresult[i]=-1; //initialize it -1
    int flag; // flag honors
    for (int i=0;i<s;i++) { // iterate students
        if (strcmp(acourse[astudent[i].courseID].name, "1")==0) { // Students find only 1 year
            int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
            flag = 1; //honors - check
            for (int j=0; j<count; j++){ // bust estimates
                if (astudent[i].rating[j]!=5 && astudent[i].rating[j]>0){ // search standouts
                    flag = 0; // if not honors, reset the flag honors
                }
            }
            if (flag==1) // add the desired array Faculty
                facultresult[astudent[i].facultyID]++;
        }
    }
    int maxfacul = -1; // number of honors
    int faculnum= -1; // number in an array of faculties
    for (int i=0; i<f; i++){
        if (facultresult[i]>maxfacul){ // if more honors
            maxfacul=facultresult[i]; // save their number
            faculnum = i; // save a room in an array of faculties
        }
    }
    if (faculnum == -1) // if not found honors
        cout << "Excellent student not found" << endl;
    else if (maxfacul>=0)
        cout << "excellent_faculty: " << afaculty[faculnum].name << endl; // derive the name of the faculty with the highest honors
}
 
void student_exception_course(){
    int courseexception[20]; // number of exceptions for courses
    for (int i=0; i<f; i++) courseexception[i]=-1; // bybwbfkbpbhetv vfccbd -1
    for (int i=0;i<s;i++) { // sorted of students
        int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
 
        int count2 = 0; // number of honors
        for (int j=0; j<count; j++){
            if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce, plus
                count2++;
            }
        }
        if (count2>=2)
            courseexception[astudent[i].facultyID]++; //if two deuces student excluded - plus course
    }
    int maxcurs = -1; // the maximum number of excluded students on the course
    int maxcursnum = -1; // number in an array of courses
    for (int i=0; i<f; i++){
        if (courseexception[i]>maxcurs){ // excluded if more
            maxcurs=courseexception[i]; // keep the number of
            maxcursnum = i; // store the number course
        }
    }
    if (maxcurs == -1) // if not excluded
        cout << "Faculty not found" << endl;
    else if (maxcurs>=0)
        cout << "max student exception course: " << acourse[maxcursnum].name << endl; // derive the name of the course with the maximum number of exceptions
}
 
void main(void) {
    cout << "Create an array of structures. Each structure consists of the following elements: faculty, course, group, names of students test scores. "<< endl;
    cout << "Implement queries by identifying: 1) the names of students who have two or more deuces per session at the Faculty of BCI and remove them, "<< endl;
    cout << "2) faculty, a freshman who has the most number of excellent and 3) the course at which the greatest excluded number of students. "<< endl;
    input();
    student_exception(); //names of students who have two or more deuces per session at the Faculty of IOT and remove them;
    excellent_faculty(); //faculty that a freshman has the largest number of nouns;
    student_exception_course(); //course at which the greatest number of students excluded.
    system ("pause");
}
0
29.12.2013, 02:44
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
29.12.2013, 02:44
Помогаю со студенческими работами здесь

Помогите с ошибкой Access violation reading location 0x1ed1d9f8.
Не могу разобраться с VS.... У меня был хороший, проверенный проект, в котором все хорошо работало...

Массивы указателей и ошибка Access violation reading location
#include &quot;stdafx.h&quot; #include &lt;iostream&gt; using namespace std; class Number { public: int...

Exception thrown at 0x77D75BCA (ntdll.dll): 0xC0000005: Access violation reading location 0x0000
Есть задача Есть решение Основное приложение: #include &quot;stdafx.h&quot; #include &lt;stdio.h&gt;...

Ошибка: Unhandled exception at 0x772115de in TimeShift.exe: 0xC0000005: Access violation reading location 0x00041000.
всем привет! При использовании двумерного массива постоянно появляется ошибка :Unhandled exception...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru