As it says, you can't pass std::string to sprintf. You should only pass char* to it. To get a char* from a string, use j.c_str();.
Though I don't think you need this at all. You can just cout << dirname << j; as you don't seem do do anything with it other than printing..
Even if you are going to use the concatenated string, you should use operator + overloaded for std::strings rather than sprinf.
If you use std::strings, there is really no reason to use character arrays and perform c functions on them at all.
sorry but i'm quiet new to c++ and programming in general, maybe my question will sound stupid, but what do you mean with "you should use operator + overloaded for std::strings ?