社区
图形处理/算法
帖子详情
错误C2664 无法将参数1从CString转换为const char*
october1993
2016-03-22 02:55:39
用的VS2015和opencv3.0
想用MFC工程做一个点击按钮,选择一张图片把图片显示出来,可是出现错误如图,求大神们指点
...全文
1074
2
打赏
收藏
错误C2664 无法将参数1从CString转换为const char*
用的VS2015和opencv3.0 想用MFC工程做一个点击按钮,选择一张图片把图片显示出来,可是出现错误如图,求大神们指点
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
puddingli
2016-03-22
打赏
举报
回复
1
改成多字节字符集就好了,或者要用Unicode字符集的话,就把代码改成cvLoadImage(CT2CA(strNamaFile),
shenyi0106
2016-03-22
打赏
举报
回复
右键点击项目,选择“属性”
在”配置属性“页,选择”常规“,找到”字符集“,改成”未设置“,保存
重新编译
C
String
,
string
,
char
*之间的
转换
随笔 - 764 文章 - 3 评论 - 196 C
String
,
string
,
char
*之间的
转换
(转) 这三种类型各有各的优点,比如C
String
比较灵活,是基于MFC常用的类型,安全性也最高,但可移植性最差。
string
是使用STL时必不可少的类型,所以是做工程时必须熟练掌握的;
char
*是从学习C语言开始就已经和我们形影不离的了,有许多API都是以
char
*作为
参数
输入的。所以熟练掌握三者之间的
转换
十分必要。 以下我用简单的图示指出三者之间的关系,并以标号对应
转换
的方法。 1
string
to C
String
C
String
.format("%s",
string
.c_str()); 2 C
String
to
string
string
str(C
String
.GetBuffer(str.GetLength())); 3
string
to
char
*
char
*p=
string
.c_str(); 4
char
* to
string
string
str(
char
*); 5 C
String
to
char
* strcpy(
char
,C
String
,sizeof(
char
)); 6
char
* to C
String
C
String
.format("%s",
char
*); C
String
的format方法是非常好用的。
string
的c_str()也是非常常用的,但要注意和
char
*
转换
时,要把
char
定义成为
const
char
*,这样是最安全的。 以上函数UNICODE编码也没问题:unicode下照用,加个_T()宏就行了,像这样子_T("%s") 补充: C
String
可能是 C
String
W/C
String
A,在与
string
转换
时,如果是 C
String
W,还涉及编码
转换
问题。下面以 C
String
A 来说明。 1
string
to C
String
C
String
.format("%s",
string
.c_str()); C
String
A =
string
.c_str() 就可以了 2 C
String
to
string
string
str(C
String
.GetBuffer(str.GetLength())); GetBuffer 有
参数
的话,可能导致内部的分配空间动作,要进行后续 ReleaseBuffer 操作。
string
= C
String
A
string
= C
String
A.GetBuffer(); 3
string
to
char
*
char
*p=
string
.c_str(); 4
char
* to
string
string
str(
char
*); 5 C
String
to
char
* strcpy(
char
*,C
String
,sizeof(
char
)); 按照 3 风格,这里应该
char
* = C
String
A; 或者
char
*p = C
String
A.GetBuffer(); 6
char
* to C
String
C
String
A =
char
* 就可以了
rsa算法设计 密码学
rsa算法设计程序 #if !defined(AFX_RSAA_H__081D9EE0_1245_11D5_80AC_0000E8810675__INCLUDED_) #define AFX_RSAA_H__081D9EE0_1245_11D5_80AC_0000E8810675__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // RsaA.h : header file // #include
#include
#include<
string
.h> #include
const
DATALENGTH=350; //大数类型的长度
const
MLENGTH=10; //质数的长度
const
TESTNUM=30; //测试质数时的比较的次数
const
SKLENGTH=4; //私钥的长度 typedef signed
char
byteint[DATALENGTH]; //定义大数类型 typedef signed
char
mtype[MLENGTH]; //定义质数的大数类型 //extern "C" __declspec(dllexport) void RsaAGenKeys(C
String
& pk,C
String
& sk,C
String
& R); //提供给服务器使用的秘钥产生函数 //extern "C" __declspec(dllexport) int RsaAEncrypt(C
String
& source,
const
char
* key,
const
char
* R,C
String
Array& result);//加密 //extern "C" __declspec(dllexport) C
String
RsaADecrypt(C
String
Array& source,
const
char
* sk,
const
char
* R);//解密 ///////////////////////////////////////////////////////////////////////////// // CRsaA command target //实现RSA算法的类 class CRsaA : public CCmdTarget { DECLARE_DYNCREATE(CRsaA) CRsaA(); // protected
const
ructor used by dynamic creation // 成员函数 private: void InitInt(void); //基本数据常量的初始化 int IntValid(byteint validtemp); //返回大数validtemp的非零位的个数 int IntCmp(byteint A,byteint B); //比较大数A和B是否相等 //自定义类型的基本运算 void Plus(byteint A,byteint B,byteint C); //C=A+B void Substract(byteint SA,byteint SB,byteint SC); //SC=SA-SB void Multiply(byteint A,byteint B,byteint C); //C=A*B void SetMode(byteint A,byteint B,byteint C,byteint D);//C=A%B int PowerMode(byteint A,byteint C,byteint D,signed
char
flag[400]);//computing A^B mod C-->D void IntRandom(byteint RandomA,int num); //随机产生一个大数 void LoadInt(byteint A,mtype B); //将质数类型
转换
为大数类型 void TransBi(byteint B,signed
char
flag[400]); //将大数B
转换
为二进制形式 void Mdata(); //产生用于生成质数中进行比较的数 int Prime(byteint Prm); //产生一个长度为MLENGTH的质数 int ComputingPK(byteint Rvalue,byteint SK,byteint PK); //计算公钥PK void ComputingR(byteint p,byteint q,byteint R); //计算模值R void ComputingRvalue(byteint p,byteint q,byteint Rvalue); //计算$(r) void IntCpy(byteint A1,byteint B1); //将大数B1的值拷贝到大数A1中 void SetZero(byteint A); //将大数A清零 C
String
PrtInt(byteint A); //将一个大数类型
转换
为一个C
String
类型 int Getinput(byteint result,C
String
input); //将字符串
转换
为对应的大数形式 int Getinput1(byteint result,unsigned long input); //将长整形数
转换
为对应的大数形式 void RsaDo(byteint source,byteint R,byteint key,byteint desti); //实现加解密 unsigned long Os2ip(unsigned
char
* pstr); C
String
Ip2os(C
String
str); public: void GenKeys(C
String
& pk,C
String
& sk,C
String
& R); //提供给服务器使用的秘钥产生函数 int RsaEncrypt(C
String
& source,
const
char
* key,
const
char
* R,C
String
Array& result);//加密 C
String
RsaDecrypt(C
String
Array& source,
const
char
* sk,
const
char
* R);//解密 void GenKeysTable(); //生成秘钥对文件 void LoadKeysFromFile(C
String
& r,C
String
& sk,C
String
& pk); //成员变量 private: byteint ONEVALUE; byteint ZEROVALUE; byteint TWOVALUE; byteint EIGHTVALUE; //O,1,2,8
const
ant mtype Model[TESTNUM]; //TESTNUM big number to be compared mtype mZEROVALUE,tempModel; //0
const
ant signed
char
flag[400]; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CRsaA) //}}AFX_VIRTUAL // Implementation //protected: virtual ~CRsaA(); // Generated message map functions //{{AFX_MSG(CRsaA) // afx_msg LONG OnComputing(WPARAM wParam, LPARAM lParam); // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations im
C
String
-
const
-
char
-
char
-to-W
CHAR
.rar_C
String
To
Char
_
char
w
char
_
UNICODE下宽字符的C
String
转换
为
const
char
和
char
到W
CHAR
的相互
转换
(
const
)
char
转C
String
详解(字符串类型
转换
详解,不断补充)
(
const
)
char
转C
String
详解(字符串类型
转换
详解,不断补充)
wince开发用
转换
类
wince上各种类型
转换
特别是字符串是很头疼的,这个类是项目用的, 每个都测试好用,使用静态方法,直接引用后,写【::cv::就可以用】 typedef int u32; //
转换
类,所有的
转换
函数在这里静态 2是to的意思 //cs:c
string
//s:
string
//i:int class cv { public: static
char
* s2
char
x(
string
s); //static
char
* cs2
char
x_unicode(C
String
s); static
char
* cs2
char
x_unicode(C
String
s); static C
String
char
x2cs(
char
*s); cv(); virtual ~cv(); static int c
string
_to_int(C
String
t); static C
String
s2cs(
string
text); static C
String
i2cs(int i); static
string
cs2s(C
String
s); static void Utf8ToUnicode(w
char
_t* pstrOut, u32 dwOutLen,
const
char
* pstrIn, u32 dwInLen); static void Gb2312ToUnicode(w
char
_t* pstrOut, u32 dwOutLen,
const
char
* pstrIn, u32 dwInLen); static C
String
string
_to_c
string
(
string
text); static int
string
_to_int(
string
str); static
string
c
string
_to_
string
(C
String
text); static void Gb2312ToUtf8(
char
* pstrOut, u32 dwOutLen,
const
char
* pstrIn, u32 dwInLen); static BOOL IsNumeric(
string
text); static void UnicodeToGb2312(
char
* pstrOut, u32 dwOutLen,
const
w
char
_t* pstrIn, u32 dwInLen); static void Utf8ToGb2312(
char
* pstrOut, u32 dwOutLen,
const
char
* pstrIn, u32 dwInLen); static int cs2i(C
String
s); static
string
int_to_
string
(int n); static C
String
ChineseCapitalMoney(double Num); //static w
string
s2ws(
string
s ); static std::w
string
s2ws(
const
string
& s); static std::
string
W
Char
2Ansi(LPCWSTR pwszSrc); static
string
ws2s(w
string
& inputws); static
const
char
* s2
const
char
x(
string
s); static std::w
string
Ansi2W
Char
(LPCSTR pszSrc, int nLen); static
char
* cs2
char
x_ansi(C
String
s); //static
string
ws2s(w
string
ws); };
图形处理/算法
19,468
社区成员
50,698
社区内容
发帖
与我相关
我的任务
图形处理/算法
VC/MFC 图形处理/算法
复制链接
扫一扫
分享
社区描述
VC/MFC 图形处理/算法
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章