|
x^y :
for (int i = 0; i < y; i++) {
x *= x;
}
of course, this doesn't work for float powers... you'll have to find a better algorithm on the web maybe, or use assembly.
if you have the/a solution, please share it with us !
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Yeh Assembly is the solution for my issue
thanks
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
Hmmm...
Waiting for it buddy.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
toxcct wrote: for (int i = 0; i < y; i++) { x *= x;}
sorry, this is incorrect code
consider where x = 2 and y = 5 (2^5)
then with above code you would be doing this
x *= 2 (x = 2 * 2)
x *= 4 (x = 4 * 4)
x *= 16 (x = 16 * 16)
x *= 256 (x = 256 * 256)
x *= 65536 (x = 65536 * 65536)
finally ending up with 4294967296 which is obviously not the correct answer
the correct code would be
int result = 1;
int y = 5;
int x = 2;
for (; y--; ) result *= x;
which would word for any arbitrary x > 0 and y >= 0
|
|
|
|
|
|
Hi,
I am working on VC++ project. Property Sheet has a number of property pages, so I want to highlight each property page TAB on its selection. Hightlight means it may paint each page TAB portion or should show same TAB text with different color.
Would you tell me the the way, How can I do it?
Thanks in advance,
Ramesh
|
|
|
|
|
You can do that in the OnSetActive() method...
Also take a look at the GetTabControl() method of the CPropertySheet Class. It returns a reference to a particular CTabCtrl object.
CTabCtrl class has a method called CTabCtrl::HighlightItem.
BOOL HighlightItem(
int idItem,
BOOL fHighlight = TRUE
);
Hope this will be sufficient for you...
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks,
I want to re-modify my question.
When we select the property sheet page tabs, then the selected page tab text should change the color of page tab text or highlight the tab text.
Error is comming from the fallowing snippet that is,
<big>Error : " 'CPropertySheet::GetTabControl' : illegal call of non-static member function"</big>
How to access the GetTabContol() from CPropertyPage derived class?
<code>BEGIN_MESSAGE_MAP(CPage2, CPropertyPage)
//{{AFX_MSG_MAP(CPage2)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CPage2::OnSetActive()
{
CTabCtrl *pTabCtrl = CPropertySheet::GetTabControl();
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = "New Label";
pTabCtrl->SetItem (1, &item );
// CTabCtrl::HighlightItem(1, TRUE);
return CPropertyPage::OnSetActive();
}</code>
wating for you reply,
- Ramesh.
|
|
|
|
|
I want to make an oracle db installer for my program. When it is executed it should be able to search the tnsnames.ora and list the services in combo box. Up to this it is finished(got the idea from http://www.codeproject.com/database/OSidList.asp)
Now, I want to:
1. logging to the service with login id and password :
2. after successful login all the users under the service should be listed. I can either choose the existing user or create a new user with sufficient rolls.
3. after that I want to execute scripts for creating tables etc. These scripts are stored in separate folder.
How will I write functions which perform the above tasks?
|
|
|
|
|
Hi all:
I'm under VC++ 7.0, and new to it. Regarding the following code
CFile file;
if ( ! file.Open(LPCTSTR ("C:\\Test.xml"), CFile::modeRead ) )
{
return;
}
After open operation why the file alway invalid?I don't see any problem!
|
|
|
|
|
LiYS wrote: if ( ! file.Open(LPCTSTR ("C:\\Test.xml"), CFile::modeRead ) )
Is Test.xml is exist at C:, as CFile::ModeRead will get failed if file requested isn't found.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: Is Test.xml is exist at C:,
That was confirmed!
|
|
|
|
|
LiYS wrote: That was confirmed!
I am lil Confused! what was confirmed?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
to complete alok's answer, don't use the cast operator to LPCTSTR this way.
change the LPCTSTR(...) into (LPCTSTR)... .
refer this[^] to understand...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 4:42 Tuesday 27th December, 2005
|
|
|
|
|
toxcct wrote: change the LPCTSTR(...) into (LPCTSTR)....
I'll try that, thanks!
But here's another Que I encountered!
I can't use GetCurrentDirectory(...), I always get compiler error saying "identifier not found". Is it because of the project I started.
I started the project as VC++/SmartDevice
|
|
|
|
|
toxcct wrote: change the LPCTSTR(...) into (LPCTSTR)....
if ( ! file.Open( (LPCTSTR)"C:\\Test.xml", CFile::modeRead ) )
doesn't works either!
|
|
|
|
|
try
if ( ! file.Open( _T("C:\\Test.xml"), CFile::modeRead ) )
<hr<span style="color:gray;size:15px;">Prakash
Prakash
|
|
|
|
|
Is the file been used by another application
i tried a code similer to the above one and it worked fine
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Are you sure there is a file with that name. Check the extension,name etc... to make sure
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
LiYS wrote: CFile file;
if ( ! file.Open(LPCTSTR ("C:\\Test.xml"), CFile::modeRead ) ) { return; }
If this code is in function X, then as soon as you leave function X, the CFile object is destroyed (it goes out of scope). Thus the file will be closed.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
hi friends
i have created one object called pIImage. I have to give the object pIImage as A argument to AddImage(). IN VARIANT type. how to convert one object to VARIANT type
eg.
hr = CoCreateInstance(CLSID_Image,NULL,CLSCTX_INPROC_SERVER,IID_IImage,(void **)&pIImage);
pDoc->AddImage(pIImage)
error C2664: 'AddImage' : cannot convert parameter 1 from 'struct XYZ5::IImage *' to 'struct tagVARIANT'
Shadrach
|
|
|
|
|
If you look more closely at VARIANT constructors (more precisely, at _variant_t , you'll notice that one of them accepts IUnknown* and bool arguments. This is exactly what you need:
pDoc->AddImage(_variant_t(pIImage, true));
|
|
|
|
|
Hi,
I created a template class, just like:
template < typename TYPE, typename TYPE_ARG = TYPE > class DataList
{
public:
void AddNode( TYPE_ARG val_i )
{
SetVal( val_i, valNew );
}
protected:
struct NODE
{
NODE* pNext;
TYPE val;
};
virtual void SetVal( TYPE_ARG valSrc_i, TYPE& valDst_o )
{
val = val_i;
}
};
This is only a model. I use this class for a general purpose linked list.
I derived a class for string handling, just like:
class StringDataList : public DataList < LPTSTR, LPCTSTR >
{
private:
void SetVal( LPCTSTR valSrc_i, LPTSTR& valDst_o )
{
valDst_o = new TCHAR[ lstrlen( valSrc_i ) ];
lstrcpy( valDst_o, valSrc_i );
}
};
Thus I can use the template class for both numeric data handling and string handling.
For example:
DataList < int, int > intDataList;
StringDataList strDataList;
The real problem is, we assume that the input parameters should be const, especially for pointers (that's why I use LPCTSTR as TYPE_ARG in StringDataList).
So the compiler shows error in the base class while compiling StringDataList.
The error is error C2440: '=' : cannot convert from 'const char *' to 'char *'
If I change the TYPE_ARG to TYPE in the SetVal of template class, another problem arises. That is in the AddNode. It is written as to pass the const input value to the SetVal. To clear it, I have to change the input from TYPE_ARG to TYPE. It is OK for all the classes passing value, but for string type, it is not advisable.
One solution is, I think, use type cast in SetVal, just like
val = TYPE( val_i )
Is there any other better solution?
Thank you.
- NS -
|
|
|
|
|
I think we had a discussion on constant string
when u had put up a question before few days.
I have already lost that data but will try again
for the same
but the changes u have done in the class are
quiet good.
Pls put up ur class on codeproj when u acomplish it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|