我在SublimeText3上使用c ++进行编码,并使用文件夹中的命令窗口手动编译并运行它,但是当我尝试使用
进行编译时g++ -Wall -pedantic -std=c++11 TheThirdTask.cpp -o TheThirdTask
(TheThirdTask.cpp是文件的名称,见下面的代码)它出现了
c:/mingnw/bin/../lib/gcc/mingw32/5.3.0/../../../libmmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of ʽvsnprintf'
C:\Users\Sam\AppData\Local\Temp\cc5MFRJe.o:TheThirdTask.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2.exe: error: 1d returned 1 exit status
我对编码很新,我只是在年初开始校队时开始,所以我不知道它是什么告诉我的。请帮忙,这是一项非常重要的任务。
TheThirdTask.cpp代码:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
int b;
int val;
int rem;
int currentVal;
string result;
cin >> b;
cin >> val;
while(val != -1){
currentVal = val;
do{
rem = currentVal%b;
if(rem > 9){
char c = rem;
c = c + 55;
result = c + result;
currentVal = floor(currentVal/b);
}
else{
result = to_string(rem) + result;
currentVal = floor(currentVal/b);
}
}while(currentVal != 0);
cout << result << endl;
cin >> val;
rem = 0;
currentVal = 0;
result = "";
}
return 0;
}
答案 0 :(得分:0)
如何尝试2个单独的命令
尝试
g++ -Wall -c TheThirdTask.cpp
然后
g++ TheThirdTask.o
上述步骤应创建一个默认名称为
的二进制文件或者只是选择
g++ -o YourBinaryName TheThirdTask.cpp
for C ++ 11
$ g++ -g -std=c++11 -Wall -pedantic TheThirdTask.cpp -o mybinary