Changeset ff9879 for molecuilder/src/helpers.cpp
- Timestamp:
- Oct 12, 2009, 12:10:43 PM (16 years ago)
- Children:
- cf4b78
- Parents:
- 7c2f6b
- git-author:
- Frederik Heber <heber@…> (10/12/09 12:04:44)
- git-committer:
- Frederik Heber <heber@…> (10/12/09 12:10:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/helpers.cpp
r7c2f6b rff9879 73 73 res *= base; 74 74 return res; 75 }; 76 77 /** Counts lines in file. 78 * Note we are scanning lines from current position, not from beginning. 79 * \param InputFile file to be scanned. 80 */ 81 int CountLinesinFile(ifstream &InputFile) 82 { 83 char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer"); 84 int lines=0; 85 86 int PositionMarker = InputFile.tellg(); // not needed as Inputfile is copied, given by value, not by ref 87 // count the number of lines, i.e. the number of fragments 88 InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines 89 InputFile.getline(buffer, MAXSTRINGSIZE); 90 while(!InputFile.eof()) { 91 InputFile.getline(buffer, MAXSTRINGSIZE); 92 lines++; 93 } 94 InputFile.seekg(PositionMarker, ios::beg); 95 Free(&buffer); 96 return lines; 75 97 }; 76 98
Note:
See TracChangeset
for help on using the changeset viewer.