|
Can you tell me more clearly...by writing one converting data type...i am very thankful to you
|
|
|
|
|
abrakadbra wrote: setQuoteToDB(Timestamp,marketno,Market,ask_d,bid_d,marketstate
This call would go like,
USES_CONVERSION;
BSTR bsTimeStamp = A2BSTR(Timestamp);
BSTR bsMarket = A2BSTR(Market);
BSTR bsBid = A2BSTR(Bid);
BSTR bsAsk = A2BSTR(Ask);
setQuoteToDB(&bsTimeStamp,&marketno,&bsMarket,&bsAsk,&bsBid,&marketstate);
SysFreeString(bsTimeStamp);
SysFreeString(bsMarket);
SysFreeString(bsBid);
SysFreeString(bsAsk);
|
|
|
|
|
I am really thankful for your effort....i am trying to solve this from past 20 days
but now i am getting error for
'setQuoteToDB' : cannot convert parameter 2 from 'class CString *' to 'short *'
How to solve this....pls
|
|
|
|
|
I have define
1)marketno and market state as CString to format(marketno.Format("%d",MarketNo);
2)marketstate.Format("%d",MarketState);
|
|
|
|
|
you are not going to hlp me anymore????pls help me....
|
|
|
|
|
To make others solve your problem, you need to give complete/clear problem definition.
You can convert CString to BSTR using CString::AllocSysString() .
|
|
|
|
|
This is the complete code i am using and geeting error for marketno,and marketstate
setQuoteToDB' : cannot convert parameter 2 from 'unsigned short ** ' to 'short *'
<br />
void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market, LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) <br />
{<br />
SessID=SessionId;<br />
CurrentRequestId=RequestId;<br />
txtMarket = Market;<br />
<br />
marketno.Format("%d",MarketNo);<br />
bid_d.Format("%c",BidDirection);<br />
ask_d.Format("%c",AskDirection);<br />
marketstate.Format("%d",MarketState);<br />
<br />
<br />
m_MainEdit=m_MainEdit + "<Price Change>" + SessionId + RequestId + marketno ; <br />
m_MainEdit=m_MainEdit + Market + Bid + bid_d + Ask +ask_d + High ;<br />
m_MainEdit=m_MainEdit + Low marketstate + Timestamp + "\r\n";<br />
<br />
UpdateData(FALSE);<br />
iLineCount=m_EditCtrl.GetLineCount();<br />
m_EditCtrl.LineScroll(iLineCount);<br />
<br />
USES_CONVERSION;<br />
BSTR bsmarketno = marketno.AllocSysString();<br />
BSTR bsTimeStamp = A2BSTR(Timestamp);<br />
BSTR bsMarket = A2BSTR(Market);<br />
BSTR bsBid = A2BSTR(Bid);<br />
BSTR bsAsk = A2BSTR(Ask);<br />
<br />
setQuoteToDB(&bsTimeStamp,&bsmarketno,&bsMarket,&bsAsk,&bsBid,&marketstate);<br />
<br />
SysFreeString(bsTimeStamp);<br />
SysFreeString(bsMarket);<br />
SysFreeString(bsBid);<br />
SysFreeString(bsAsk);<br />
<br />
<br />
Error:
<br />
setQuoteToDB' : cannot convert parameter 2 from 'unsigned short ** ' to 'short *'<br />
|
|
|
|
|
abrakadbra wrote: setQuoteToDB(&bsTimeStamp,&bsmarketno,&bsMarket,&bsAsk,&bsBid,&marketstate);
Second parameter is short* , you need to pass address of MarketNo .
Your call would be like ;
setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&marketstate);
|
|
|
|
|
i have no word to say thank you
Thanks again..now it is ok...
|
|
|
|
|
i am using this to convert my CString variable to int type.....can anybody help me what went wrong it is not working.....
<br />
ASSERT(_tcstoul(db_TQuote.m_MarketName == _ttoi(Market)));<br />
ASSERT(_tcstoul(db_TQuote.m_MarketState == _ttoi(marketstate));<br />
ASSERT(_tcstoul(db_TQuote.m_Ask == _ttoi(ask_d));<br />
ASSERT(_tcstoul(db_TQuote.m_Bid== _ttoi(bid_d));<br />
ASSERT(_tcstoul(db_TQuote.m_DateTimeStamp== _ttoi(timestamp));<br />
ASSERT(_tcstoul(db_TQuote.m_MarketNo== _ttoi(marketno))<br />
<br />
|
|
|
|
|
What are you doing ?
abrakadbra wrote: ASSERT(_tcstoul(db_TQuote.m_MarketName == _ttoi(Market)));
What is datatype of Market ? I'm assuming it is string .
What is db_TQuote.m_MarketName ?
Input to _tcstoul will be bool instead of string as expected.
This code should not compile in first place.
|
|
|
|
|
|
Once you get your conversion issue worked out (follow the advice of the other posters) take a look at this thread. ASSERT[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
is there any function in vc++ to convert char to char*
Thank you
|
|
|
|
|
&
e.g.
char ch = 'a';
char *pChar = &ch;
Be aware that when ch goes out of scope pChar is no longer valid.
Steve
|
|
|
|
|
If you have a char, as in
char c = 'a';
then you can get the address with &c. However, there's a problem. All the things I can think you'd want to use a char * for, assuming that the char * is a valid string until it hits a null. So, you need to do this:
char * cp = new char[2];
cp[0] = c;
cp[1] = NULL;
Then you have a pointer to a string of one character length.
Overall, you'd do better to use std::string.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I would like to know how to predefine the name of socket in the security blocking?
Please help!
|
|
|
|
|
Greetings,
How do I make my class evaluate to a fundamental type? For example, one of my classes has a member variable that holds a number (i.e. type "int"). How do I make it so that this class (i.e. CMoneyClass BigMoney) can a) be cast as an int (i.e. int nSalary = (int)BigMoney) or that an expression involving my class evaluates to an int (i.e. a function with the declaration: SetBonus(int nSalary), can be used in the code as: SetBonus(BigMoney))?
Thank you. Any help you can provide would be greatly appreciated.
BP
|
|
|
|
|
A casting operator will work...
class CMoneyClass
{
int m_MyInt;
...
public:
operator int() const {return m_MyInt;}
...
};
|
|
|
|
|
Wow, that is awesome! So essentially I overload the casting operator in my class, and that solves both the casting issue and I can use it in any place that actually calls for an "int" (in other words, I don't have to cast it as an "int", it will automatically evaluate to an "int")?
|
|
|
|
|
Yes and the implementation doesn't have to be as simple as the example. You can write it like
any other function as long as it returns an int.
Also, you can have other type cast operators if needed.
Mark
|
|
|
|
|
Thanks Mark,
Do you know where I can find information on how to do this?
BP
|
|
|
|
|
BlitzPackage wrote: Do you know where I can find information on how to do this?
Do which?
I was just mentioning that the implementation of the operator(s) (or any operators) doesn't
need to be a simple inline function. You could do calculations, access a database, whatever it
takes to return a meaningful value of the type cast. If you break the implementation out of
the class declaration, the syntax looks like this:
class CMoneyClass
{
int m_MyInt;
...
public:
operator int() const;
operator double() const;
...
};
CMoneyClass::operator int() const
{
return m_MyInt;
}
CMoneyClass::operator double() const
{
return (double)m_MyInt;
}
I also added a different casting operator to show how you could have more than one.
Lame example but it works.
Here's a link: C++ Language Reference Cast Operator: ()[^]
Mark
|
|
|
|
|
Thanks Mark,
Your answers are very helpful.
Peace,
BP
|
|
|
|
|
My program get a warning
warning C4995: 'strcpy': name was marked as #pragma deprecated
strcpy(buff,"#test.\r\n");
I should disable the warning or using other function!
If using other function, which I should used.
I would like to have your suggestion!
Please help!
|
|
|
|