C++ Concating Streicher Ergebnis "ungültige Operanden der Typen" const char* " und "const char"

Ich möchte concat-zwei strings, aber ich bekomme Fehler, dass ich nicht verstehe, wie zur überwindung dieser Fehler.

Gibt es eine Möglichkeit zur Konvertierung const char* zu char? Sollte ich einige dereferenzieren?

../src/main.cpp:38: error: invalid operands of types const char*’ and const char [2]’ to binary operator+’
make: *** [src/main.o] Error 1

Jedoch, wenn ich versuche zu machen, bis "unten" string diese Weise funktioniert es:

bottom += "| ";
bottom += tmp[j];
bottom += " ";

Hier ist der code.

#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 j = 0; j < tmp.size(); j++)
        {
            if(tmp[j] != ' ')
            {
                top += "+---";
                bottom += "| " + tmp[j] + " ";
            } else {

            }
        }
        cout << top << endl;
        cout << bottom << endl;
    }

    return 0;
}
bottom += "| " + tmp[j] " "; zu bottom += "| " + tmp[j] + " ";
Oh, sorry, das habe ich mir kopiert. Nein, es ist sogar, wenn ich es beheben.

InformationsquelleAutor booka | 2013-04-03

Schreibe einen Kommentar