#include "stdio.h"
#include "stdlib.h"int main(void)
{
CString array_[7]={
"<KeyWord name=\"#if\" />",
"<KeyWord name=\"#ifdef\" />",
"<KeyWord name=\"#ifndef\" />",
"<KeyWord name=\"#include\" />",
"<KeyWord name=\"#line\" />",
"<KeyWord name=\"#pragma\" />",
"<KeyWord name=\"#undef\" />"
};
CString res = "";
res.Format(array_[6]);
cout<<res<<endl;
int position = res.Find("<KeyWord name=\"");
int position1 = res.Find("\" />",14);
//cout<<"子字符串的位置为(逆向查找)"<<position<<endl; int ch = res.Delete(0,15); cout<<"结果为 "<<res<<endl;
res.TrimRight("\" />");
cout<<"最终结果为 "<<res<<endl; return 0;
}
我都包含了头文件,为什么还是编译出处啊?提示错误如下:-------------------------------------------------------
error C2065: 'CString' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'array_'
error C2065: 'array_' : undeclared identifier
error C2109: subscript requires array or pointer type
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2143: syntax error : missing ';' before '}'
error C2146: syntax error : missing ';' before identifier 'res'
error C2065: 'res' : undeclared identifier
error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2228: left of '.Format' must have class/struct/union type
error C2109: subscript requires array or pointer type
warning C4552: '<<' : operator has no effect; expected operator with side-effect
error C2228: left of '.Find' must have class/struct/union type
error C2228: left of '.Find' must have class/struct/union type
error C2228: left of '.Delete' must have class/struct/union type
error C2297: '<<' : illegal, right operand has type 'char [9]'
error C2228: left of '.TrimRight' must have class/struct/union type
error C2297: '<<' : illegal, right operand has type 'char [13]'
#include <afx.h>再编译试试?
res.Format(array_[6]) Format的用法不对
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
这怎么解决啊
http://msdn.microsoft.com/en-us/library/aa314327(v=vs.60).aspx
你建的什么工程啊?你这样设置试试:project->setting,然后选中 “General”,在下拉框选择“Use MFC in a Shared DLL”,然后 clean,Rebuild All 试试,
哈哈,搞定了,为什么要用MFC 的这些DLL 啊?不用不行么?不过,终于编译没错了,谢谢啦