• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

CString undeclared in C++ when build

I had error C2065: 'CString' : undeclared identifier when building win32 console app EXE. I need to use CString variable in the future. how to get it valid?

Thanks.
#include <iostream>
 
using namespace std;
void main()
{
  CString s;
 
  cout << "Hello World!" << endl;   
  cout << "Welcome to C++ Programming" << endl; 
}
 
After build:
Deleting intermediate files and output files for project 'AA - Win32 Debug'.
--------------------Configuration: AA - Win32 Debug--------------------
Compiling...
AA_test.cpp
c:\myproject\aa\aa_test.cpp(8) : error C2065: 'CString' : undeclared identifier
c:\myproject\aa\aa_test.cpp(8) : error C2146: syntax error : missing ';' before identifier 's'
c:\myproject\aa\aa_test.cpp(8) : error C2065: 's' : undeclared identifier
Error executing cl.exe.
 
AA.exe - 3 error(s), 0 warning(s)

Open in new window

0
Jing272
Asked:
Jing272
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
I see you are using STL classes too. Why not use std::string class instead?
0
 
Jing272Author Commented:
string works excellent. Many thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now