I'm writing a simple code to read systemized data from .txt file, and got warning "C6386: Buffer overrun while writing to 'points': the writable size is 'num*8' bytes, but '16' bytes might be written". How to solve it in my case ? Code attached.
struct point {
int x, y;
};
void main()
{
fstream file;
point* points;
int num,
i = 0;
file.open("C:\\Users\\Den\\Desktop\\file.txt", fstream::in);
if (!file.is_open()) {
cout << "No file found\n";
exit(1);
}
else {
file >> num;
points = new point[num];
}
while (file >> num) {
points[i].x = num; // <- here
file >> num;
points[i].y = num;
i++;
}
file.close();
}
i? What isnum(the first value)? I mean their values for your input file.txt ;) - gsamarasnumentries in the file? Be a good time to edit the question to add a small sample input that triggers the error so we can see what's up. - user4581301