I have a single string that i need to do a couple of concatenations to. This is my first time dealing with strings in cpp and the methods I need to use seems to be taking a char* and not std::string. this is what i need to do:
String folderpath = "something";
folderpath +="/"+dbName;
mkdir(folderpath);
foo(folderpath + "/" +dbName + ".index");
bar(folderpath + "/" +dbName + ".db");
This is how i've managed to do it in C++ and it looks so bad. Is there a better way?
char* folderPath = getenv("CAVEDB_ROOT_FOLDER");
strcat(folderPath, "/");
strcat(folderPath, dbName);
mkdir(folderPath);
char* indexfile;
char* dbfile;
strcpy(indexfile, folderPath);
strcpy(dbfile, folderPath);
strcat(indexfile, "/");
strcat(indexfile, dbName);
strcat(indexfile, ".index")
strcat(dbfile, "/");
strcat(dbfile, dbName);
strcat(dbfile, ".db");
foo(indexfile);
bar(dbfile);