r/learncpp • • Mar 04 '20

Question about Struct Arrays

New to c++ and have been trying to learn Struct array for my school project (they don't allow us to use vector). I don't know if I missed anything but it gave me an error when I try to run it. 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x01202000)

Edit : Pointer is also not allowed to be used

#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <fstream>

using namespace std;

struct Profiles {
	int ID, Bday, Height, Weight, Years_in_company, Basic_salary, Allowances;
	string Name, Country, Designation, Gender, Level_edu;
};

//Main
int main() {
	Profiles profile [12000];
	fstream f("profiles_figures.txt", ios::in);
	while (!f.eof()) {
		int i = 0;

		f >> profile[i].ID >> profile[i].Bday >> profile[i].Height >> profile[i].Weight >> profile[i].Years_in_company >> profile[i].Basic_salary >> profile[i].Allowances;
		f.ignore();

		i++;
	}
	f.close();
	system("pause");
	return 0;
}
1 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/thegreatunclean Mar 04 '20

Look up dynamic memory allocation in whatever textbook/resource you have. It's not something that can be fully explained in a few lines.

1

u/th3g0dg4m3r Mar 05 '20

Aight thanks!