what is the difference between this and the code I had? from what I see they should do the same thing but when I test my code and try to display the contents of the array it doesnt display anything, only spaces, and i get into an endless loop, your code displays the right amount of times but not what I have in the file, it displays what I have in the default constructor
void displayAll(Houselist house[], int num)
{
charconst* fname = "houseinfo.txt" ;
std::ifstream readfile(fname) ;
if ( !readfile.is_open() )
{
std::cerr << "Unable to open file " << fname << '\n' ;
return ;
}
int num ;
int i = 0 ;
while ( i < num && readfile >> num )
house[i++].setNumber(num) ;
if ( i < num )
std::cerr << "Unable to read " << num << " values from " << fname << '\n' ;
}