![]() |
【转帖】problem using getfilename
problem using getfilename
problem using getfilename i have just upgraded to vs2005 and downloaded the new libraries. now i have encountered a problem with the 2.5.1 libraries: (lpctstr)pdb->getfilename().c_str(); returns "c" i was trying to pass the filename as a cstring object to a function. however, if i do: afxmessagebox(pdb->getfilename()) it shows the full path. so what has changed here? andrew if i remove the .c_str() from my code then it works ok. but this code was fine for vc6 libraries. andrew i think the effect is caused not by changing compiler but by changed meaning of lpctstr (unicode / char) pdb->getfilename().c_str() returns pointer to odchar (unicode string) if lpctstr is char* than explicit cast to it casts wchar_t* to char* - you see single character. if lpctstr is wchar_t* than it works ok. after removing .c_str() it works always because odstring operator (const char*) correctly converts unicode string to char. or odstring operator (const wchar_t*) is invoked depending on meaning of lpctstr. sergey slezkin |
所有的时间均为北京时间。 现在的时间是 03:43 AM. |