1
#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++ を使用しており、正規表現用のファイルをそれぞれのlibbin、および" C:\Dev-Cpp " のincludeフォルダーに抽出しましたが、プログラムをコンパイルしようとすると、まだ次のエラーが表示されます。

'regex' 宣言されていません (最初にこの関数を使用してください)

4

1 に答える 1

0

#include <regex.h>条件付きインクルードを使用した場合など、ステートメントに到達しない場合、コンパイラからこのエラー メッセージが表示されます。

#include <regex.h>実際に到達していることを確認してください。の条件付きインクルードを使用してインクルードを誤って除外し、でコードを試したときにも、このエラーメッセージが表示されました。

于 2016-06-06T22:12:26.220 に答える