Thread: MVC++ Cstring question

  1. #1
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    MVC++ Cstring question

    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 = )

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    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

  3. #3
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    Oi

    But it doesn't seem to work for me =(

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    How doesn't it work?
    zen

  5. #5
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    : )

    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

  6. #6
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. c style string memory leak question
    By curlious in forum C++ Programming
    Replies: 7
    Last Post: 09-14-2003, 06:31 AM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. MFC:: CString & Serialize ::C++
    By kuphryn in forum C++ Programming
    Replies: 0
    Last Post: 02-22-2002, 03:31 PM