Z
zhouchengly
when I use the following code to get integer values from file:
void getIntegers()
{
vector<ItemType > items;
ifstream ifs("test.dat");
//¿¼ÂÇΪitemsÒ»´Î·ÖÅä¿Õ¼ä¡£
ItemType item ;
while( !ifs.eof() )
{
ifs>>item;
items.push_back(item);
}
}
if test.dat is ended with a carriage return, "ifs>>item" will not fail
but doesn't change item's value. this is not I want.
using try...catch having no effect.
So is there an stardard way to get integer(float) from a file? the file
format is like this.
//////test.dat
101
22
35
//end with a carriage return
void getIntegers()
{
vector<ItemType > items;
ifstream ifs("test.dat");
//¿¼ÂÇΪitemsÒ»´Î·ÖÅä¿Õ¼ä¡£
ItemType item ;
while( !ifs.eof() )
{
ifs>>item;
items.push_back(item);
}
}
if test.dat is ended with a carriage return, "ifs>>item" will not fail
but doesn't change item's value. this is not I want.
using try...catch having no effect.
So is there an stardard way to get integer(float) from a file? the file
format is like this.
//////test.dat
101
22
35
//end with a carriage return