Duong Thai Ha wrote: > > > Hi > > Thanks a lot > > I have tried and there is error. C++ can not convert from char* to const > char* > I have to use the const_cast <char*> and it work
Not correct. For converting from char* to const char*, no const_cast is required. But for converting from const char* to char*, const_cast is required. In the current situation you are doing a conversion from const char* to char*, and hence the need for const_cast. Rgds, anna > Thanks once more > > Annamalai Gurusami wrote: > > > > duongthaiha wrote: > > > > > > > > > Hi > > > Sorry for a new bee question. > > > > > > I am trying to have a method > > > > > > void output2file(char* filename) > > > > > > but when i pass the parameter, the parameter is string. > > > Is there any way to change from string to char* > > > > I assume that you are using C++ std::string. In that case you can make > > use of the c_str() member function of std::string. For example, > > > > string w; > > const char *p = w.c_str(); > > > > Rgds, > > anna > > > > > > > > Thanks a lot > > > I reall do appreciate your help > > > > > > Best regard > > > > > > > > -- Always acknowledge a fault. This will throw those in authority off their guard and give you an opportunity to commit more. - Mark Twain
