void GamessukOut::readInitialCoordinates(std::ifstream& ifs) { // string to mark end of the coordinates char coordEnd[86] = " " "********************************************************" "********************"; double x = 0.0, y = 0.0, z = 0.0; // skip five lines ifs.getline(buffer, BUFF_SIZE) && ifs.getline(buffer, BUFF_SIZE) && ifs.getline(buffer, BUFF_SIZE) && ifs.getline(buffer, BUFF_SIZE) && ifs.getline(buffer, BUFF_SIZE); while (strstr(buffer, coordEnd) == nullptr) { // std::cout << "COORD line" << buffer << std::endl; // ifs.getline(buffer, BUFF_SIZE); tokenize(tokens, buffer, " \t\n"); if (tokens.size() == 8) { // std::cout << "Coord line" << buffer << std::endl; gukBasis.atomLabels.push_back(tokens.at(1)); from_string<double>(x, tokens.at(3), std::dec); from_string<double>(y, tokens.at(4), std::dec); from_string<double>(z, tokens.at(5), std::dec); gukBasis.coordinates.push_back( Eigen::Vector3d(x, y, z)); // Want coordinates in Bohr } ifs.getline(buffer, BUFF_SIZE); } }
void GlowNodeGroup::open(std::ifstream& fp) { int type = 0; int end_found = 0; char dummy[40]; for (;;) { if (!fp.good()) { fp.clear(); fp.getline(dummy, sizeof(dummy)); printf("** Read error GlowNodeGroup: \"%d %s\"\n", type, dummy); } fp >> type; switch (type) { case glow_eSave_NodeGroup: break; case glow_eSave_NodeGroup_nodeclass_part: GlowNodeClass::open(fp); break; case glow_eSave_End: end_found = 1; break; default: std::cout << "GrowGroup:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } }
// ================== (2) PC variables ==================== // void DetectorGeo::ReadPROP(std::ifstream &file) { char ReadIn[280]; // skip to and over the + sign do { file.getline(ReadIn,280,'\n'); } while(ReadIn[0] != '+'); // Radius, thickness of mylar foil in PC file>>rp_myl>>tp_myl; // std::cout << "Mylar radius, thickness " << rp_myl << " "<<tp_myl <<"\n"; //Total number of foils in prop. chamber file >> npfoils; // std::cout<<"npfoils " << npfoils <<std::endl; //position the Mylar foils defining PC wire planes for(int ipfoil=0; ipfoil<npfoils; ipfoil++) { file >> zpfoil[ipfoil]; // std::cout << ipfoil << " " << zpfoil[ipfoil] << "\n"; } // skip to and over the + sign do { file.getline(ReadIn,280,'\n'); } while(ReadIn[0] != '+'); // Radius, length of PC sense wires, spacing between wires in PC and, // Number of physical wires/PC plane file >> pw_rad >> pw_len >> pw_space >> npwires_physical; // std::cout << "pw_rad, pw_len, pw_space, npwires_physical \n"; // std::cout << pw_rad << " " << pw_len << " " << pw_space << " " // << npwires_physical << "\n"; //Total number of prop planes and Thickness of gas volume file >>npplanes>>tp_plane; // std::cout<<"npplanes, tp_plane " << npplanes << tp_plane<<std::endl; // skip to and over the + sign do { file.getline(ReadIn,280,'\n'); } while(ReadIn[0] != '+'); // plane positions in PC int plane; for(int ipplane=0; ipplane<npplanes; ipplane++) { file >> plane >> zpplane[ipplane] >> pshift[ipplane] >> prot[ipplane] >> npwires[ipplane]; // std::cout << ipplane << " " <<zpplane[ipplane]<< " " <<pshift[ipplane] // << " " <<prot[ipplane]<< " " <<npwires[ipplane]<< "\n"; } }
MMFormatInput::MMFormatInput(std::ifstream &in, std::vector<uint32_t> &permIn) : MatrixInput(), in(in), curRow(0), curIndex(-1), already_read(false), perm(permIn) { //read header only char buf[500]; isBinary = false; in.getline(buf, 500); if ( strstr(buf, "pattern") != NULL ) { isBinary = true; } do { in.getline(buf, 500); if (in.gcount() >=500){ cerr << "FAILED FORMAT" << endl; exit(1); } } while (buf[0] == '%'); uint32_t nr, nc, nnz; sscanf( buf , "%d %d %d", &nr, &nc, &nnz); this->nnz = nnz; this->numRows = nr; this->numCols = nc; if (perm.size() == 0) { perm.resize( max(numRows, numCols) ); for (int i=0; i<perm.size(); i++) { perm[i] = i; } } }
void GlowText::open(std::ifstream& fp) { int type = 0; int end_found = 0; char dummy[40]; char tmp_text[500]; int tmp; for (;;) { if (!fp.good()) { fp.clear(); fp.getline(dummy, sizeof(dummy)); printf("** Read error GlowText: \"%d %s\"\n", type, dummy); } fp >> type; switch (type) { case glow_eSave_Text: break; case glow_eSave_Text_text_size: fp >> text_size; break; case glow_eSave_Text_draw_type: fp >> tmp; draw_type = (glow_eDrawType)tmp; break; case glow_eSave_Text_color_drawtype: fp >> tmp; color_drawtype = (glow_eDrawType)tmp; break; case glow_eSave_Text_text: fp.get(); fp.getline(tmp_text, sizeof(tmp_text)); free(text); text = (char*)malloc(strlen(tmp_text) + 1); strcpy(text, tmp_text); break; case glow_eSave_Text_p: p.open(fp); break; case glow_eSave_End: end_found = 1; break; default: std::cout << "GlowText:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } }
void Tpetra::Utils::readHBHeader(std::ifstream &fin, Teuchos::ArrayRCP<char> &Title, Teuchos::ArrayRCP<char> &Key, Teuchos::ArrayRCP<char> &Type, int &Nrow, int &Ncol, int &Nnzero, int &Nrhs, Teuchos::ArrayRCP<char> &Ptrfmt, Teuchos::ArrayRCP<char> &Indfmt, Teuchos::ArrayRCP<char> &Valfmt, Teuchos::ArrayRCP<char> &Rhsfmt, int &Ptrcrd, int &Indcrd, int &Valcrd, int &Rhscrd, Teuchos::ArrayRCP<char> &Rhstype) { int Totcrd, Neltvl, Nrhsix; const int MAXLINE = 81; char line[MAXLINE]; // Title.resize(72 + 1); std::fill(Title.begin(), Title.end(), '\0'); Key.resize(8 + 1); std::fill(Key.begin(), Key.end(), '\0'); Type.resize(3 + 1); std::fill(Type.begin(), Type.end(), '\0'); Ptrfmt.resize(16 + 1); std::fill(Ptrfmt.begin(), Ptrfmt.end(), '\0'); Indfmt.resize(16 + 1); std::fill(Indfmt.begin(), Indfmt.end(), '\0'); Valfmt.resize(20 + 1); std::fill(Valfmt.begin(), Valfmt.end(), '\0'); Rhsfmt.resize(20 + 1); std::fill(Rhsfmt.begin(), Rhsfmt.end(), '\0'); // const std::string errStr("Tpetra::Utils::readHBHeader(): Improperly formatted H/B file: "); /* First line: (A72,A8) */ fin.getline(line,MAXLINE); TEUCHOS_TEST_FOR_EXCEPTION( std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line."); (void)std::sscanf(line, "%72c%8[^\n]", Title.getRawPtr(), Key.getRawPtr()); /* Second line: (5I14) or (4I14) */ fin.getline(line,MAXLINE); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line."); if ( std::sscanf(line,"%14d%14d%14d%14d%14d",&Totcrd,&Ptrcrd,&Indcrd,&Valcrd,&Rhscrd) != 5 ) { Rhscrd = 0; TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%14d%14d%14d%14d",&Totcrd,&Ptrcrd,&Indcrd,&Valcrd) != 4, std::runtime_error, errStr << "error reading pointers (line 2)"); } /* Third line: (A3, 11X, 4I14) */ fin.getline(line,MAXLINE); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line."); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line, "%3c%14i%14i%14i%14i", Type.getRawPtr(),&Nrow,&Ncol,&Nnzero,&Neltvl) != 5 , std::runtime_error, errStr << "error reading matrix meta-data (line 3)"); std::transform(Type.begin(), Type.end(), Type.begin(), static_cast < int(*)(int) > (std::toupper)); /* Fourth line: */ fin.getline(line,MAXLINE); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line."); if (Rhscrd != 0) { TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%16c%16c%20c%20c",Ptrfmt.getRawPtr(),Indfmt.getRawPtr(),Valfmt.getRawPtr(),Rhsfmt.getRawPtr()) != 4, std::runtime_error, errStr << "error reading formats (line 4)"); } else { TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%16c%16c%20c",Ptrfmt.getRawPtr(),Indfmt.getRawPtr(),Valfmt.getRawPtr()) != 3, std::runtime_error, errStr << "error reading formats (line 4)"); } /* (Optional) Fifth line: */ if (Rhscrd != 0 ) { Rhstype.resize(3 + 1,'\0'); fin.getline(line,MAXLINE); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line."); TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%3c%14d%14d", Rhstype.getRawPtr(), &Nrhs, &Nrhsix) != 3, std::runtime_error, errStr << "error reading right-hand-side meta-data (line 5)"); } }
int UserList::load(std::ifstream& fp) { int type; int end_found = 0; char dummy[40]; for (;;) { fp >> type; switch (type) { case user_eData_User: break; case user_eData_UserName: fp.get(); fp.getline(name, sizeof(name)); break; case user_eData_UserPassword: fp.get(); fp.getline(password, sizeof(password)); break; case user_eData_UserPrivilege: fp >> priv; priv = idecrypt(priv); break; case user_eData_UserId: fp >> id; break; case user_eData_UserFullName: fp.get(); fp.getline(fullname, sizeof(fullname)); break; case user_eData_UserDescription: fp.get(); fp.getline(description, sizeof(description)); break; case user_eData_UserEmail: fp.get(); fp.getline(email, sizeof(email)); break; case user_eData_UserPhone: fp.get(); fp.getline(phone, sizeof(phone)); break; case user_eData_UserSms: fp.get(); fp.getline(sms, sizeof(sms)); break; case user_eData_End: end_found = 1; break; default: std::cout << "User:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } return 1; }
void _readDocumentHeader() { char line[65536]; if( !_in.good() || _in.eof() ) return; // DOCNO= _in.getline( _docno, sizeof _docno-1 ); // DOCURL= _in.getline( line, sizeof line-1 ); // LINKS= _in.getline( line, sizeof line-1 ); _count = atoi( line+6 ); }
/** * This helper method just moves forward the two file pointers to skip some header lines. * @param numLinesToSkip The number of header lines to skip */ void SkipHeaderLines(unsigned numLinesToSkip) { if (!mCalledCollectively || PetscTools::AmMaster()) { for (unsigned line_number=0; line_number<numLinesToSkip; line_number++) { char buffer[1024]; mpFile1->getline(buffer, 1024); mpFile2->getline(buffer, 1024); TS_ASSERT(!mpFile1->fail()); // Here we assume there are at least "ignoreFirstFewLines" lines... TS_ASSERT(!mpFile2->fail()); // ...and that they are lines of no more than 1024 characters mLineNum++; } } }
void GrowSlider::open(std::ifstream& fp) { int type = 0; int end_found = 0; char dummy[40]; int tmp; for (;;) { if (!fp.good()) { fp.clear(); fp.getline(dummy, sizeof(dummy)); printf("** Read error GrowSlider: \"%d %s\"\n", type, dummy); } fp >> type; switch (type) { case glow_eSave_GrowSlider: break; case glow_eSave_GrowSlider_direction: fp >> tmp; direction = (glow_eDirection)tmp; break; case glow_eSave_GrowSlider_max_value: fp >> max_value; break; case glow_eSave_GrowSlider_min_value: fp >> min_value; break; case glow_eSave_GrowSlider_max_pos: fp >> max_pos; break; case glow_eSave_GrowSlider_min_pos: fp >> min_pos; break; case glow_eSave_GrowSlider_grownode_part: GrowNode::open(fp); break; case glow_eSave_End: end_found = 1; break; default: std::cout << "GrowSlider:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } }
/** * Loads the header of a glove data file. * This is both for the samples and for the trained files. * * The header format is: * -Comments -- # starting<br> * - num gestures<br> * -Gesture names<br> * -Gesture samples<br> * * @param infile A file that is already open and ready for reading. * After running, this routines will leave the file pointer * immedately after the header. */ void GloveGesture::loadFileHeader(std::ifstream& infile) { // skip comments while(infile.peek() == '#') infile.ignore(4096, '\n'); // Ignore the entire line. // Get num gestures int num_gestures; infile >> num_gestures; // Get the number of gestures infile.ignore(4096, '\n'); // Ignore the rest of the line // Get gesture names int i; char gest_name[512]; mGestureNames = std::vector<std::string>(num_gestures); for(i=0; i<num_gestures; i++) { infile.getline(gest_name,512); mGestureNames[i] = std::string(gest_name); } mGestureExamples = std::vector<GloveData>(num_gestures); // Get gesture data for(i=0; i<num_gestures; i++) mGestureExamples[i].inputAngles(infile); }
void ResourceManager::getI2NBlock(std::ifstream &file, Resource::Mapping &mapping, bool files, const std::string &dir, const std::string &ext) { uint id; const int bufferSize = 80; char buffer[bufferSize]; while (!file.eof() && file.peek() != '#') { file >> id; if (!(file.peek() == '.')) return; file.ignore(2, ' '); file.getline(buffer, bufferSize); fixLineEnd(buffer); if (files) { std::string path = dir + '/' + std::string(buffer) + ext; Normalize(path); mapping[id] = path; } else { mapping[id] = std::string(buffer); } } }
// Load next chromosome ref_loc_t RefSeq::LoadNextSeq(std::ifstream &fin) { char c; char ch[1000]; std::string s; fin>>c; if (fin.eof()) return 0; _length = 0; // get name fin>>_name; fin.getline(ch, 1000); // get seq while (!fin.eof()) { fin>>c; if (fin.eof()) break; fin.unget(); if (c == '>') break; fin>>s; if (_length + s.size() >= param.max_dbseq_size) { if (s.size() > param.append_dbseq_size) { param.max_dbseq_size += (s.size() + 10); } else { param.max_dbseq_size += param.append_dbseq_size; } _seq.resize(param.max_dbseq_size); } copy(s.begin(), s.end(), _seq.begin() + _length); _length += s.size(); } return _length; }
void ReadWorldTagData( std::ifstream &inStream, UString &tag, UString &data ) { char temp[4096]; tag = "o---o"; data = "o---o"; while( !inStream.eof() && !inStream.fail() ) { inStream.getline( temp, 4096 ); UString sLine( temp ); sLine = sLine.removeComment().stripWhiteSpace(); if( !sLine.empty() ) { if( sLine != "o---o" ) { if( sLine.sectionCount( "=" ) == 1 ) { tag = sLine.section( "=", 0, 0 ).stripWhiteSpace(); data = sLine.section( "=", 1 ).stripWhiteSpace(); break; } } else break; } } }
int CSheet::loadFrom(std::ifstream& in) { int lines = 0; while(!in.eof()) { //读取其中一行 char line[256] = {0}; in.getline(line, 255); CString s = /*(CString)*/static_cast<CString>(line); //空白行则跳过 if (s.IsEmpty()) continue; //#为注释标记,跳过 if (s[0]=='#') continue; //如果读到字母则跳过 if (s[0]>='a' && s[0]<='z') continue; CStringArray* pRow = new CStringArray(); int i = 0; CString token = s.Tokenize(_T(",\t"), i); while (token!=_T("")) { pRow->Add(token); token = s.Tokenize(_T(",\t"), i); } m_rows.Add(pRow); lines++; } return lines; }
void l1menu::TriggerMenu::loadMenuInOldFormat( std::ifstream& file ) { const size_t bufferSize=200; char buffer[bufferSize]; while( file.good() ) { try { // Get one line at a time file.getline( buffer, bufferSize ); // split the line by whitespace into columns std::vector<std::string> tableColumns=l1menu::tools::splitByWhitespace( buffer ); if( tableColumns.size()==1 && tableColumns[0].empty() ) continue; // Allow blank lines without giving a warning if( tableColumns.size()!=12 ) throw std::runtime_error( "The line does not have the correct number of columns" ); addTriggerFromOldFormat( tableColumns ); } // end of try block catch( std::runtime_error& exception ) { std::cout << "Some error occured while processing the line \"" << buffer << "\":" << exception.what() << std::endl; } } }
bool FastaFile::readLine() { int n; ifsIn.getline(pcLine, nMaxLineLength); if ( pcLine[0] == '>' ) { if ( curSeqIndex >= 0 ) { updateCurrentSequenceInfo(); } std::vector<std::string> tokens; tokenizeString(pcLine, tokens); curSeqName = tokens[0].substr(1); // make SeqName without leading '>' MD5Init(&curMD5Ctx); curSeqLength = 0; ++curSeqIndex; } else { n = strlen(pcLine); // convert to upper-case for calculating FASTA MD5 for(int i = 0; i < n; ++i) { pcLine[i] = toupper(pcLine[i]); } MD5Update(&curMD5Ctx, (unsigned char*)pcLine, n); curSeqLength += n; } ++nCurrentLine; return ifsIn.good(); }
void readline(std::string* dst, std::ifstream& stream) { char buf[1024]; do { stream.clear(); stream.getline(buf, 1024); *dst += buf; } while( stream.fail() && !stream.eof() ); }
int SystemList::load(std::ifstream& fp) { int type; int end_found = 0; char dummy[40]; for (;;) { fp >> type; switch (type) { case user_eData_SystemName: fp.get(); fp.getline(name, sizeof(name)); break; case user_eData_SystemLevel: fp >> level; break; case user_eData_SystemAttributes: fp >> attributes; break; case user_eData_SystemId: fp >> id; break; case user_eData_SystemDescription: fp.get(); fp.getline(description, sizeof(description)); break; case user_eData_User: load_user(fp); break; case user_eData_System: load_system(fp); break; case user_eData_End: end_found = 1; break; default: std::cout << "System:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } return 1; }
void next_line(std::ifstream& fin, char* line, size_t LINE_SIZE) { do { if (fin.eof()) { throw IOError("Error parsing OFF file"); } fin.getline(line, LINE_SIZE); } while(strlen(line) == 0 || line[0] == '#' || line[0] == '\n' || line[0] == '\r'); }
bool GamessukOut::parseFile(std::ifstream& ifs) { /** * Loop through the file, calling routines that read in the data of interest * into the GUKBasisSet object * Is currently pretty rudimentary - could do with lots of error trapping to * check all o.k. */ bool gotMOs = false; // used as return value - indicates if we have valid // orbitals for the coordinates we've read in while (ifs.good() && ifs.getline(buffer, BUFF_SIZE)) { // First find oriented geometry - use this for single-point calculations if (strstr(buffer, " * atom atomic coordinates") != nullptr) { readInitialCoordinates(ifs); } // The basis set definition if (strstr(buffer, " atom shell type prim exponents " " contraction coefficients") != nullptr) { readBasisSet(ifs); } // Determine the scftype - can't do uhf yet if (strstr(buffer, " * SCF TYPE") != nullptr) { tokenize(tokens, buffer, " \t\n"); if (tokens[3].compare(0, 6, "rhf") != 0) { std::cerr << "ERROR: can currently only do rhf!\n"; return false; } } // The converged geometry if (strstr(buffer, "optimization converged") != nullptr) { readOptimisedCoordinates(ifs); if (gotMOs) gotMOs = false; // If we read in some MOs they are now redundant } // The molecular orbitals if (strstr( buffer, " eigenvectors") != nullptr || strstr(buffer, " molecular orbitals") != nullptr) { readMOs(ifs); gotMOs = true; } } return gotMOs; }
bool configfile::line_after (std::ifstream & file, const std::string & tag) { bool result = false; file.clear(); file.seekg(0, std::ios::beg); file.getline(m_line, sizeof(m_line)); while (! file.eof()) { result = strncmp(m_line, tag.c_str(), tag.length()) == 0; if (result) break; else file.getline(m_line, sizeof(m_line)); } (void) next_data_line(file); return result; }
QDateTime getRecordTime(std::ifstream &inFile, float &X, float &Y, float &Z) { char record[100]; inFile.getline(record, 100); std::istringstream stream(&record[0]); char date[100]; stream >> date >> X >> Y >> Z; return QDateTime::fromString(date, "yyyy-MM-dd_hh:mm:ss.zzz"); }
void state::populate(std::ifstream &file) { char row[50], *p, temp[5]; char ipSymbol = 'a', ip; int s; file.get(op); file.get(); file.getline(row, 50); p = row; while(*p!='\0') { std::sscanf(p, "%s", temp); if(temp[0] == '~') { } else if(temp[0] == 'F') { finalState = true; } else { tCount++; ip = ipSymbol; s = temp[0] - 48; transitionTable = (struct transition *) std::realloc(transitionTable, sizeof(transition) * tCount); transitionTable[tCount - 1].ip = ip; transitionTable[tCount - 1].t = s + 48; /* if(s < sCount) //Transiting to a preceding state { transitionTable[tCount - 1].t = s + 48; } else { refTable = (struct globalRef *) std::realloc(refTable, sizeof(globalRef) * (s+1)); // refTable[s].addr = new state; transitionTable[tCount - 1].t = refTable[s].stateName = s + 48; } */ } while(*p != ' ') { if(*p == '\0') { p--; break; } p++; } p++; ipSymbol++; } }
static bool getline_cr(std::ifstream& istr, char* str, std::streamsize count) { istr.getline(str,count); bool ret = static_cast<bool>(istr); size_t sz = strlen(str); if (ret && str[sz-1] == '\r') { str[sz-1] = '\0'; } return ret; }
/******************** SUPPORT FUNCTIONS *********************/ size_t nextReadPosition(std::ifstream& ifs, size_t off = 0) { ifs.seekg(off); size_t candidate = off; char line[MAX_BUFFER_SIZE]; line[0] = 0; // look for the first occurance of '@' at the beginning of a line while(line[0] != '@' && !ifs.eof()) { candidate = ifs.tellg(); ifs.getline(line, MAX_BUFFER_SIZE); } // end of file reached and no reads have been found if (ifs.eof()) { return off; } size_t tmp = ifs.tellg(); // read the next line to double check that '@' defines a proper start of a read ifs.getline(line, MAX_BUFFER_SIZE); candidate = (line[0] != '@') ? candidate : tmp; return candidate; }
void sayLine( int lineNumber ) { std::cout << _filename << "(" << lineNumber << ") : "; char line[MAX_LINESIZE]; _file.seekg(0); for(int i=0; i<lineNumber; i++) _file.getline(line, MAX_LINESIZE); std::cout << line << std::endl; }
void CTubeLoader::ReadVertex(std::ifstream &in, char strLine[]) { Vector3f vec; in >> vec.x; in >> vec.z; in >> vec.y; in.getline(strLine,256); m_pVertices.push_back(vec); }//end ReadVertex
void CTubeLoader::ReadTexCoord(std::ifstream &in, char strLine[]) { CVector2f vec; in >> vec.x; in >> vec.y; m_pTexCoords.push_back(vec); //cout<<m_pTexCoords.size()<<" "<<vec.x<<" "<<vec.y<<endl; in.getline(strLine,256); }//end ReadTexCoord
bool MEDITParser::skip_field(std::ifstream& fin) { const size_t LINE_SIZE = 256; char line[LINE_SIZE]; size_t num_lines=0; fin >> num_lines; for (size_t i=0; i<num_lines; i++) { fin.getline(line, LINE_SIZE); if (!fin.good()) return false; } return true; }