【发布时间】:2017-09-14 14:59:04
【问题描述】:
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
string argstr[argc];
for(int c = 1; c++; c<argc) {
argstr[c].assign(argv[c]);
}
for(int c = 1; c++; c<argc) {
__asm__(argstr[c]); //This is where the error occurs
cout << argstr[c] << endl;
}
}
如果我尝试用 MinGW 编译它,我会收到以下错误:
Main.cpp:在函数'int main(int,char**)'中: Main.cpp:15:6:错误:“args”之前的预期字符串文字 asm(参数);我知道这一点,这就是我将参数分配给字符串向量的原因。
【问题讨论】:
-
A std::string 不是字符串文字。
-
字符串文字是一个字符串,其值在源代码中表示为用引号括起来的字符
"like this"。在运行时不可能组装任何东西。
标签: c++