user63898
user63898

Reputation: 30895

CString 'Trim' : is not a member, why?

I have simple app that I try to compile with VC express and using the:
Microsoft platform SDK for Windows server 2003 that contains MFC and ATL. Now I have this simple code :

CString strValue("test");
CString s = strValue.Trim();
LPCTSTR lpStr = (LPCTSTR)strValue.Trim()

that give me a compilation error : c:\dev\test.cpp(463) : error C2039: 'Trim' : is not a member of 'CString' c:\program files\microsoft platform sdk for windows server 2003 r2\include\mfc\afx.h(369) : see declaration of 'CString'

do I have a problem with the platform SDK and vc express?

Upvotes: 6

Views: 7824

Answers (3)

vividos
vividos

Reputation: 6748

Using the MFC from the "Microsoft Platform SDK for Windows Server 2003 R2" seems to install an earlier version of MFC where CString doesn't have the Trim() function yet. Use TrimLeft() and TrimRight() in combination instead.

This link to the Visual C++ 6 version of CString documentation shows that the method doesn't exist there, yet: http://msdn.microsoft.com/en-us/library/aa315043%28v=vs.60%29.aspx

Upvotes: 0

Sunscreen
Sunscreen

Reputation: 3564

You could try TrimLeft(), TrimRight() functions of CString instead.

Upvotes: 2

lornova
lornova

Reputation: 6933

Visual C++ Express Edition don't has built in support for ATL and MFC (CString is an MFC class, implemented as the shared MFC/ATL CStringT class: documentation).

If you really can't afford the Standard Edition, you can rely on this howto to add ATL and MFC support by installing the DDK: http://www.codeproject.com/KB/MFC/MFCinVisualStudioExpress.aspx

Upvotes: 5

Related Questions