我之前使用过这个确切的函数,但只是复制并粘贴到另一个文件导致它停止工作。唯一的变化是我添加了“using namespace std”。
在我的“ReadData()”函数中,我在getline(cin,data)上遇到一个错误,即没有重载函数的实例与参数列表匹配。此外,我在调用中的“数据”中收到错误,称“数据不明确”。
该函数应该从文本文件中读取数据并将文本行存储在数据中以供进一步处理。这个功能确实如此,所以我只是不确定。
#include <iostream>
#include "NvraArray.h"
#include "NvraRecord.h"
#include <vector>
#include <string>
#include <ctime>
using namespace std;
// Globals
string data; // Stores the line that getline is at
vector<string> rows; // Stores the rows of data
vector<int> recordNumbersSeen; // Holds records numbers that have been checked
string strWords[24]; // Holds the individual columns of data for processing
int rowCounter = 0; // Counts the rows of data coming in
// Prototypes
// Reads the data from cin into the "rows" vector
void ReadData();
// Checks the current row against the list of records already seen
bool isDuplicate(int recordID);
// Checks the current row for invalid data
bool isValidData();
// Splits the row into an array to process
void SplitRowIntoArray(std::string row);
int main(){
// For testing purposes
srand(time(NULL));
NvraArray array;
NvraRecord record;
system("pause");
return 0;
}
void ReadData(){
while(getline(cin,data)){
// if on the first row, do nothing and skip to the next.
if(rowCounter != 0){
rows.push_back(data);
}else{
rowCounter++;
}
}
rowCounter = 0;
}