error C2440: '=' : cannot convert from 'char [14]' to 'char [20]'
2014-11-13 20:03
453 查看
1、是这样错的:pDataConects->strDataBaseIP =TEXT( "192.168.0.112");而这个结构体是这样定义的:
#ifndef DEF_STRUCT_DATABASECRED
#define DEF_STRUCT_DATABASECRED
typedef struct _DataBaseCred
{
TCHAR strDataBaseIP[20];
ULONG uDataBasePort;
TCHAR strDataBaseName[256];
TCHAR strDataBaseUserName[256];
TCHAR strDataBasePassword[256];
TCHAR strUserName[256];
TCHAR strPassword[256];
}DataBaseCred,*PDataBaseCred;
#endif
没仔细看它的数据类型,竟然是数组,首地址固定了,因此只能用_tcscpy.
2、改正后:strcpy(pDataConects->strDataBaseIP,"192.168.0.112");
#ifndef DEF_STRUCT_DATABASECRED
#define DEF_STRUCT_DATABASECRED
typedef struct _DataBaseCred
{
TCHAR strDataBaseIP[20];
ULONG uDataBasePort;
TCHAR strDataBaseName[256];
TCHAR strDataBaseUserName[256];
TCHAR strDataBasePassword[256];
TCHAR strUserName[256];
TCHAR strPassword[256];
}DataBaseCred,*PDataBaseCred;
#endif
没仔细看它的数据类型,竟然是数组,首地址固定了,因此只能用_tcscpy.
2、改正后:strcpy(pDataConects->strDataBaseIP,"192.168.0.112");
相关文章推荐
- error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR' 原因
- 2014-04-02工作日志:error C2440: 'initializing' : cannot convert from 'char [8]' to 'unsigned short *'
- error C2440: '=' : cannot convert from 'char ** ' to 'char *** '
- string转Char*( error C2440: '=' : cannot convert from 'const char *' to 'char *')
- 轻松解决——error C2440: '=' : cannot convert from 'char [???]' to 'LPWSTR'
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTrunkPage::* )(void)' to 'void (__thiscall CCmdTarget::* )(N
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESUL
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESU
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESUL
- error C2664:cannot convert parameter 2 from 'char [260]' to 'LPWCH'
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall MenuToolBar::* )(LPARAM,LRESULT *)' to 'void (__thiscall CCmd
- 使用atoi 报错:cannot convert parameter 1 from '_TCHAR *' to 'const char *'
- 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' 解决方案
- cannot convert parameter 1 from 'CString' to 'const char *'
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall MenuToolBar::* )(LPARAM,LRESULT *)' to 'void (__thiscall CCmd
- error C2440: 'initializing' : cannot convert from 'unsigned long' to 'void *
- VC++ 出现错误:cannot convert from const char *' to 'LPCWSTR' 或者'const char [7]' to 'LPCWSTR' 的解决方法
- cannot convert parameter 1 from 'const char *' to 'LPCWSTR
- 类型转换 -- 使用Unicode下的cannot convert parameter 1 from 'CString' to 'const char *' 解决办法
- error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_