linux測試boost是否安裝成功

#include <iostream>
#include <string>
#include <boost/regex.hpp>

int main()
{
    std::string tmpStr= "192.168.0.1";

    boost::regex expression("([0-9]+).([0-9]+).([0-9]+)");
    boost::smatch what;

    if(boost::regex_search(tmpStr, what, expression))
    {
        std::cout << what.size() << std::endl;
        for(size_t i = 0; i < what.size(); i++)
        {
            if(what[i].matched)
            {
                std::cout << what[i] << std::endl;
            }
        }
    }

    return 0;
}

Makefile

INC_DIR=-I/usr/include/
LIB_DIR=-L/usr/lib64/
LIB=-lboost_regex

CC=g++ -g
CFLAGS=-Wall
EXE=test

all:
	$(CC) $(CFLAGS) $(EXE).cpp -o $(EXE) $(INC_DIR) $(LIB_DIR) $(LIB)

clean:
	rm -rf *.o $(EXE)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章