I was wondering if anyone knew how to convert the strings Microsoft Visual C++ uses (the cstring type) into normal char arrays for manipulation with strcat and such... This may be a very stupid question but I'd like to know... Thanks = )
I was wondering if anyone knew how to convert the strings Microsoft Visual C++ uses (the cstring type) into normal char arrays for manipulation with strcat and such... This may be a very stupid question but I'd like to know... Thanks = )
This appears to work -
Code:#include <iostream> #include <cstring> #include <afx.h> using namespace std; int main() { CString s = "foo"; strcat(s.GetBuffer(10),"bar"); cout << (LPCTSTR)s; return 0; }
zen
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd.lib(delop.obj)
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/prog1.exe : fatal error LNK1120: 2 unresolved externals
Since your question was about CString, I assumed that you already had an MFC app. If you want the code to work then you'll have to select Project/Settings/General and change the setting in the combo box that presently has "Not Using MFC" in it.
zen