str1.Format("%d",i);
str = str+str1;
int i=11;
CString str="test";
CString addition;
addition.Format("%d",i);
str+=addition;
就可以了。
11。关于sprintf类型转换的问题
sprintf(buf,"select price from ls01 where p_date>='%'",t_date)
其中t_date是CTime类型,%后面应该是什么呢?%s是String类型,%c是char,那么CTime型对应的是什么呢?
sprintf(buf,"select price from ls01 where p_date>='%S'",(LPCSTR)t_date.Format( "%A, %B %d, %Y" ));
如果不行,就
char temp[50];
CString str=t_date.Format( "%A, %B %d, %Y" );
strcpy(temp,(LPCSTR)str);
sprintf(buf,"select price from ls01 where p_date>='%S'",temp);
CTime::Format返回CString
wait
don't know
SQL语句中日期要写成字符串"yyyymmdd"
12。类型转换 unsigned int <==>CString??
发表时间:2001-12-17 10:25:23
unsigned int f;//unsigned int 0~4294967295
CString g;
f=2300000000;
g.Format("%d",f);
AfxMessageBox(g);
出错。
unsigned int f;//unsigned int 0~4294967295
CString g;
f=2300000000;
g.Format("%d",f);
MessageBox(g);//使用AfxMessageBox,需要窗口的句炳参数
我 AfxMessageBox(g); 和MessageBox(g); 都不错。
错的是g.从 2300000000=》1994967296
是2300000000=》-1994967296 类型转换错。
g.Format("%u",f);
to dgsnmpoperate 那怎么从 CString ==>>unsigned int
既然是 unsigned int,
超过 0x7f000000 (2130706432) 当然不能用 %d (signed int)用%u
CString ==>>unsigned int
char *p = (LPSTR)(LPCSTR) g;
f = atoi(p);
13。static_cast、dynamic_cast 和直接类型转换(如 (void *)p )的区别?
发表时间:2001-12-14 9:31:13
先拷贝MSDN中的一小段话:
class B { ... };
class C : public B { ... };
class D : public C { ... };
void f(D* pd)
{
C* pc = dynamic_cast<C*>(pd); // ok: C is a direct base class
// pc points to C subobject of pd
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-27731-10.html
太绝对了
很感动