Brainless Beginner trying to use CString

Started by
6 comments, last by chris1962 22 years, 6 months ago
I'm sure there is something really basic I'm missing, but here is my problem. I'm working in VisualC++ and trying to use the CString class, and keep getting the following error on my compile: error C2065: 'CString' : undeclared identifier My code snipet is: #include "string.h" #include "stdio.h" CString s1 = "some text here"; Any help would be greatly appreciated. Thanks, Chris In the mood for a little Fun & Games? Check out www.SunAndGames.com Home of Lost Enticer Edited by - chris1962 on October 14, 2001 5:26:21 PM
Indie in training . . . www.GamesForSail.comMy life as a blogger . . . Blog Blog Blog . . . Blah Blah Blah
Advertisement
It looks like the CString object is not on String.h ... try put string.h in <>

just a guess...
I''ve tried that, but it still get the same error.

In the mood for a little Fun & Games?
Check out www.SunAndGames.com
Home of Lost Enticer
Indie in training . . . www.GamesForSail.comMy life as a blogger . . . Blog Blog Blog . . . Blah Blah Blah
To use CString you have to use MFC (or part of it). It''s in the header file.
Oops... didn''t come out right... the afx.h header file.
I tried add "afx.h", and get the following error:

fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include "windows.h"

I believe I'm already using MFC, because I have some MFC functions working already (FindWindows, SetWindowsHookEx).

Could this problem be because I'm doing this in a DLL?

In the mood for a little Fun & Games?
Check out www.SunAndGames.com
Home of Lost Enticer


Edited by - chris1962 on October 14, 2001 5:45:05 PM

Edited by - chris1962 on October 14, 2001 5:45:33 PM
Indie in training . . . www.GamesForSail.comMy life as a blogger . . . Blog Blog Blog . . . Blah Blah Blah
Only use CString in an MFC app

Use the std::string if you want reusable code
  #include <STRING>   

No .h

Or the _bstr_t in the "COMUtil.h" header for a b-string/unicode helper.

Edited by - Magmai Kai Holmlor on October 14, 2001 5:52:00 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
It works now. I just had to remove a windows.h in my own DLL header, and add the afx.h instead.

Thanks for the help.
Chris
Indie in training . . . www.GamesForSail.comMy life as a blogger . . . Blog Blog Blog . . . Blah Blah Blah

This topic is closed to new replies.

Advertisement