2013-04-10 1 views

답변

1
using namespace std; 
int discardInt; 
string strInput; 
double dblInput; 

vector<string> strings; 
vector<double> doubles; 

ifstream infile("filename.txt"); //open your file 

while(infile >> discard >> strInput >> dblInput) { 
    //now discard stores the value 1, which you don't use; 
    //strInput stores Gt or other 1-3 character long string; 
    //dblInput stores the double 

//operations to store the values that are now in strInput and dblInput 
//for example, to push the values into a vector: 
    strings.push_back(strInput); 
    doubles.push_back(dblInput); 

} 

infile.close(); 
1

꽤 평범한 물건.

ifstream file(...); 
string line; 
while (getline(file, line) 
{ 
    istringstream buf(line); 
    int dummy; 
    string tag; 
    double val; 
    buf >> dummy >> tag >> val; 
} 

tagval는 1.003