mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
47 lines
955 B
C++
Executable File
47 lines
955 B
C++
Executable File
#include"util.h"
|
|
#include<fstream>
|
|
|
|
using namespace std;
|
|
|
|
namespace vb01{
|
|
void readFile(string path, vector<string> &lines, int firstLine, int lastLine){
|
|
string l;
|
|
std::ifstream inFile(path);
|
|
for(int i = 0; i < lastLine && getline(inFile,l); i++){
|
|
if(i >= firstLine)
|
|
lines.push_back(l);
|
|
}
|
|
inFile.close();
|
|
}
|
|
|
|
void getLineData(string &line, string data[], int numData, int offset){
|
|
int offsetComma = 0, c1 = 0;
|
|
for(int i = 0; i < line.length() && offsetComma < offset; i++)
|
|
if(line.c_str()[i] == ' '){
|
|
c1 = i + 1;
|
|
offsetComma++;
|
|
}
|
|
int c2 = c1;
|
|
for(int i = 0; i < numData; i++){
|
|
for(int j = c1; j < line.length(); j++)
|
|
if(line.c_str()[j] == ' '){
|
|
c2 = j;
|
|
break;
|
|
}
|
|
data[i] = line.substr(c1, c2 - c1);
|
|
c2++;
|
|
c1 = c2;
|
|
}
|
|
}
|
|
|
|
int getCharId(char ch){
|
|
int charId = -1;
|
|
for(int i = 0; i < line.length(); i++)
|
|
if(line[i] == ch){
|
|
colonId = i;
|
|
break;
|
|
}
|
|
return charId;
|
|
}
|
|
}
|