-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Morning +7;
struct person {
person() {
for (int i = 0; i < 1000; i++)
friends[i] = 9999;
id = idcounter;
idcounter++;
}
bool ifisfriend(int id) {
for (int i = 0; i < 1000; i++) {
if (friends[i] == 9999)
return false;
if (friends[i] == id)
return true;
}
}
void makefriend(int id) {
friends[friendcounter] = id;
friendcounter++;
}
void breakup(int id) {
for (int i = 0; i < 1000; i++) {
if (friends[i] == id)
friends[i] = 9999;
}
}
void setid() {
id = 9999;
}
int getid() {
return id;
}
static int friendcounter;
int friends[1000];
int id;
static int idcounter;
};
My struct defination is above, but the gdb tells me that Segmentation fault occured in the scope below. why is that, could you explain it to me ? THX.
person mike, jack, lily, carson, sucie;
Metadata
Metadata
Assignees
Labels
No labels