void graph::fillTable()
{
ifstream fin;
char X;
int slot=0;
fin.open(\"data.txt\");
while(fin.good()){
fin>>Gtable[slot].Name;
fin>>Gtab
Try moving first two reads in the while condition:
// assuming Gtable has at least size of 1
while( fin>>Gtable[slot].Name && fin>>Gtable[slot].Out ) {
cout<>X;
cout<
Edit: As per James Kanze's comment, you're taking an adress past the end of Gtable
array, which is what causes segfault. You could pass the size of Gtable
as argument to your fillTable() function (f.ex. void fillTable(int table_size)
) and check slot
is in bounds before each read.