为什么这个C ++程序不会编译? [英] Why won't this C++ program compile?
本文介绍了为什么这个C ++程序不会编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我想要编译的程序。
This is the program I'm trying to compile.
#include <iostream>
#include <string>
#include <vector>
#include <unistd.h>
using namespace std;
vector<string> paramlist;
const char *programname = "abc";
const char **args = new const char* [paramlist.size()+2]; // extra room for program name and sentinel
args [0] = programname; // by convention, args[0] is program name
for (int j = 0; j < paramlist.size()+1; ++j) // copy args
args [j+1] = paramlist[j] .c_str();
args [paramlist.size()+1] = NULL; // end of arguments sentinel is NULL
execv (programname, (char **)args);
当我尝试编译它,我得到这些错误消息:
When I try to compile it I get these error messages:
test.cpp:11: error: expected constructor, destructor, or type conversion before ‘=’ token
test.cpp:12: error: expected unqualified-id before ‘for’
test.cpp:12: error: expected constructor, destructor, or type conversion before ‘<’ token
test.cpp:12: error: expected unqualified-id before ‘++’ token
test.cpp:15: error: array bound is not an integer constant
test.cpp:15: error: expected constructor, destructor, or type conversion before ‘=’ token
test.cpp:17: error: expected constructor, destructor, or type conversion before ‘(’ token
推荐答案
您至少需要 int main
函数。
You at least need an int main
function.
这篇关于为什么这个C ++程序不会编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文