#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <regex.h>
using namespace std;
string input;
int main()
{
//Input .ply file
ifstream inputFile ("input.ply");
//input file is read
if (inputFile.is_open())
{
int i = 1; //Line iterator
int vertices = 0;
int faces = 0;
vector<float> anatomy;
vector<float> normals;
vector<int> triangles;
string a,line;
getline(cin,line);
while (inputFile.good())
{
//Take number from line 4, set as variable "vertices"
if (i == 4)
{
regex pattern("[^0-9]+");
getline (inputFile,line);
vertices = show_match(line, pattern);
}
//Take number from line 11, set as variable "triangles"
if (i == 11)
{
regex pattern("[^0-9]+");
getline (inputFile,line);
faces = show_match(line, pattern);
}
if (i == 13)
{
i++;
break;
}
i++;
}
waitKey(0);
}
else
{
cout << "Cannot read mesh, please try again." << endl;
}
return 0;
}
只是尝试从字符串中读取并提取整数,因此我添加了正则表达式标头和其他文件以便使用正则表达式。我正在使用Dev-C ++并将正则表达式的文件解压缩到“ C”中各自的 lib , bin 和 include 文件夹中:\ Dev-Cpp “,但是当我尝试编译程序时,我仍然收到以下错误:
'正则表达'未声明(首先使用此功能)