简体   繁体   English

正则表达式未声明(Dev C ++)

[英]regex undeclared (Dev C++)

#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;

}

Just trying to read from a string and extract the integer, so I have added the regex header and other files in order to use regular expressions. 只是尝试从字符串中读取并提取整数,所以为了使用正则表达式,我添加了regex标头和其他文件。 I'm using Dev-C++ and have extracted the files for regex into their respective lib , bin and include folders in " C:\\Dev-Cpp ", but I am still receiving the following error when I attempt to compile my program: 我正在使用Dev-C ++,并将regex的文件提取到各自的libbininclude文件夹中的“ C:\\ Dev-Cpp ”中,但是在尝试编译程序时仍收到以下错误:

'regex' undeclared (first use this function) 未声明“ regex”(首先使用此功能)

You will get this error msg from the compiler if your statement #include <regex.h> is not reached, for example if you used conditional includes. 如果未达到您的语句#include <regex.h> ,例如,如果您使用了条件包含, #include <regex.h>从编译器获得此错误消息。

Make sure that #include <regex.h> is actually reached. 确保实际到达#include <regex.h> I got this error message too when I accidentally excluded the include by using a conditional include for and then trying the code with . 当我通过为使用条件include意外排除包含,然后使用尝试代码时,我也收到了此错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM