ये धागे मुझे जवाब नहीं है:stringstream का पुन: उपयोग करने के लिए कैसे
How do you clear a stringstream variable?
std::ifstream file(szFIleName_p);
if(!file) return false;
// create a string stream for parsing
std::stringstream szBuffer;
std::string szLine; // current line
std::string szKeyWord; // first word on the line identifying what data it contains
while(!file.eof()){
// read line by line
std::getline(file, szLine);
// ignore empty lines
if(szLine == "") continue;
szBuffer.str("");
szBuffer.str(szLine);
szBuffer>>szKeyWord;
szKeyword
हमेशा पहला शब्द में शामिल होंगे, szBuffer
रीसेट किया जा रहा है, एक नहीं मिल सकता है स्ट्रिंगस्ट्रीम का उपयोग करने के तरीके पर कहीं भी स्पष्ट उदाहरण। जवाब के बाद
नए कोड:
std::string szLine; // current line
std::string szKeyWord; // first word on the line identifying what data it contains
// read line by line
while(std::getline(file, szLine)){
// ignore empty lines
if(szLine == "") continue;
// create a string stream for parsing
std::istringstream szBuffer(szLine);
szBuffer>>szKeyWord;
संभावित डुप्लिकेट [ओस्टिंगस्ट्रीम का पुन: उपयोग कैसे करें?] (Http://stackoverflow.com/questions/624260/how-to-reuse-an-ostringstream) – maxschlepzig