c++ ifstream with a variable filename -
i'm trying open file wich name composed constant , variable parts.
my actual code
char filename[100]; char extension1[] = ".pdb"; vector<string> id; //code find ids(it works) sprintf(filename, "/home/giovanni/scrivania/enzimi/ligan/%s", id[1].c_str()); sprintf(filename, "%s%s", filename,extension1);
the problem filenames becomes
.pdbe/giovanni/scrivania/enzimi/ligan/102m
instead of
/home/giovanni/scrivania/enzimi/ligan/102m.pdb
tnx in advance
simply use std::string:
string filename = "/home/giovanni/scrivania/enzimi/ligan/" + id[1] + ".pdb"; ... std::ifstream file(filename.c_str());
Comments
Post a Comment