cstring 头文件
场景:很菜的有关问题,CString引用的头文件
很菜的问题,CString引用的头文件
代码如下:
#include <afx.h>
using namespace std;
#include "stdafx.h "
int main(int argc, char* argv[])
{
CString a;
printf( "Hello World!\n ");
char s = getchar();
return 0;
}
编译提示:
Compiling...
TEST.cpp
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2065: 'CString ' : undeclared identifier
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2146: syntax error : missing '; ' before identifier 'a '
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2065: 'a ' : undeclared identifier
Error executing cl.exe.
TEST.exe - 3 error(s), 0 warning(s)
正确引用CString需要加载的头文件是那些?请问
------解决方案--------------------
mfc工程才能用
------解决方案--------------------
VC8中是
cstringt.h MFC-only string objects
atlstr.h Non-MFC string objects
VC6是
#include <afx.h> 不过,还依赖其他文件,所以新建一个支持mfc的工程吧
------解决方案--------------------
使用win32控制台应用程序也能调通的啊,按Alt+F7,在C/C++的Category中选Code Generation,然后Use run-time library选Multithreaded,然后我直接写的代码:
#include <afx.h>
#include <iostream.h>
#include <time.h>
#include <afxtempl.h>
void main()
{
CString MyString;
CTime t=CTime::GetCurrentTime();
cout < <t.GetYear() < <endl < <t.GetDayOfWeek()
< <endl < <t.GetTime() < <endl < <t.GetGmtTm()-> tm_year < <endl;
MyString=t.Format( "%A, %B %d, %Y ");
cout < <t.GetLocalTm()-> tm_year < <endl < <MyString;
}
也能运行的。
------解决方案--------------------
你既然用了std,那就用std中的string类吧,也很方便的.
std::string
http://msdn2.microsoft.com/en-us/library/syxtdd4f(VS.80).aspx
------解决方案--------------------
#define __cplusplus
------解决方案--------------------
重建个MFC的工程吧
很菜的问题,CString引用的头文件
代码如下:
#include <afx.h>
using namespace std;
#include "stdafx.h "
int main(int argc, char* argv[])
{
CString a;
printf( "Hello World!\n ");
char s = getchar();
return 0;
}
编译提示:
Compiling...
TEST.cpp
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2065: 'CString ' : undeclared identifier
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2146: syntax error : missing '; ' before identifier 'a '
D:\iES600\src\tools\TEST\TEST.cpp(17) : error C2065: 'a ' : undeclared identifier
Error executing cl.exe.
TEST.exe - 3 error(s), 0 warning(s)
正确引用CString需要加载的头文件是那些?请问
------解决方案--------------------
mfc工程才能用
------解决方案--------------------
VC8中是
cstringt.h MFC-only string objects
atlstr.h Non-MFC string objects
VC6是
#include <afx.h> 不过,还依赖其他文件,所以新建一个支持mfc的工程吧
------解决方案--------------------
使用win32控制台应用程序也能调通的啊,按Alt+F7,在C/C++的Category中选Code Generation,然后Use run-time library选Multithreaded,然后我直接写的代码:
#include <afx.h>
#include <iostream.h>
#include <time.h>
#include <afxtempl.h>
void main()
{
CString MyString;
CTime t=CTime::GetCurrentTime();
cout < <t.GetYear() < <endl < <t.GetDayOfWeek()
< <endl < <t.GetTime() < <endl < <t.GetGmtTm()-> tm_year < <endl;
MyString=t.Format( "%A, %B %d, %Y ");
cout < <t.GetLocalTm()-> tm_year < <endl < <MyString;
}
也能运行的。
------解决方案--------------------
你既然用了std,那就用std中的string类吧,也很方便的.
std::string
http://msdn2.microsoft.com/en-us/library/syxtdd4f(VS.80).aspx
------解决方案--------------------
#define __cplusplus
------解决方案--------------------
重建个MFC的工程吧