相关疑难解决方法(0)

传递命令行参数

好吧,我已经更新了我的代码,但我仍然不确定如何使用我传递的命令行参数的向量.我试着像我下面的代码一样设置它,但它不会编译.它给我一个错误,它无法找到argc和argv:

1> c:\ users\chris\documents\visual studio 2008\projects\cplusplustwo\cplusplustwo\application.h(32):错误C2065:'argc':未声明的标识符1> c:\ users\chris\documents\visual studio 2008\projects\cplusplustwo\cplusplustwo\application.h(32):错误C2065:'argv':未声明的标识符

main.cpp中

#include "application.h"

int main(int argc,char *argv[]){
    vector<string> args(argv, argv + argc);
    return app.run(args);    
}
Run Code Online (Sandbox Code Playgroud)

application.h

#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "time.h"
using namespace std;



class application{
private:
    //Variables
    boost::regex expression;
    string line;
    string pat;
    string replace;
    int lineNumber;
    char date[9];
    char time[9];


    void commandLine(vector<string> args){
        string  expression="";    // Expression
        string  textReplace="";   // Replacement Text
        string  inputFile="";     // Input File
        string  outputFile="";    // Output …
Run Code Online (Sandbox Code Playgroud)

c++ command-line vector

2
推荐指数
1
解决办法
7150
查看次数

在C ++中将文件名作为参数传递

我必须在c ++程序的参数中传递四个不同的文本文件。我如何通过??

c++

1
推荐指数
1
解决办法
3069
查看次数

标签 统计

c++ ×2

command-line ×1

vector ×1