我想连接两个字符串,但我得到错误,我不明白如何克服此错误.
有没有办法将此const char*转换为char?我应该使用一些解除引用吗?
../src/main.cpp:38: error: invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’
make: *** [src/main.o] Error 1
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试以这种方式组成"底部"字符串,它的工作原理:
bottom += "| ";
bottom += tmp[j];
bottom += " ";
Run Code Online (Sandbox Code Playgroud)
这是代码.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <iterator>
#include <sstream>
int main(int argc, char* argv[]) {
ifstream file("file.txt");
vector<string> mapa;
string line, top, bottom;
while(getline(file,line)){
mapa.push_back(line);
}
string tmp;
for(int i = 0; i < mapa.size(); i++)
{
tmp = mapa[i];
for(int …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的sqlite3表"地址":
+----+------+--------+
| ID | name | number |
+----+------+--------+
| 1 | John | 413434 |
+----+------+--------+
Run Code Online (Sandbox Code Playgroud)
我想填充全局矢量,我可以在其他地方使用它并将其与其他一些数据连接起来.到目前为止,我有这个:
...
#include <sqlite3.h>
using namespace std;
static int callbackDB(void *NotUsed, int argc, char **argv, char **szColName)
{
for(int i = 0; i < argc; i++)
cout << szColName[i] << " = " << argv[i] << endl;
return 0;
}
int main(int argc, char* argv[]) {
vector<vector<string> > table;
for( int i = 0; i < 2; i++ )
table.push_back(std::vector< std::string >()); …Run Code Online (Sandbox Code Playgroud)