[Sorry for posting so much code, but this is the main loop of a vector implementation of the problem. Same functions/struct etc as before]
Code:
int main ( void )
{
std::ifstream in ( "thing.txt" );
if ( !in )
{
in.close();
return 1;
}
std::string temp;
Info info;
std::vector<Info> infoVec;
while ( getline( in, temp, ',' ) )
{
info.price = lexical_cast< double, std::string > ( temp );
getline( in, temp, ',' );
info.serialNum = lexical_cast< int, std::string > ( temp );
getline( in, temp, ',' );
info.descript = temp;
getline( in, temp, '\n' );
info.order = lexical_cast< int, std::string > ( temp );
infoVec.push_back( info );
}
in.close();
for ( int i=0; i!=(int)infoVec.size(); i++ )
{
std::cout<< '\n' << i << " :: Price: " << infoVec[i].price;
std::cout<< '\n' << i << " :: Serial: " << infoVec[i].serialNum;
std::cout<< '\n' << i << " :: Description: " << infoVec[i].descript;
std::cout<< '\n' << i << " :: Order: " << infoVec[i].order << '\n';
}
return 0;
}