|
Can i use atoi function????plz check this??
s[20]=11100001110
int power = 1;
int sum = 0;
for (int i = l-1; i >= 0; l--)
{sum += power * atoi(s[i]);
power = power * 2;
}
printf("%d", sum)
|
|
|
|
|
but atoi fuction si not working
|
|
|
|
|
Why go to all of this trouble when strtoul() will work just fine?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
yes, i need it so... the value of 11100001110. i,e some 1806 or so...
|
|
|
|
|
I am not sure what you mean with masking, but if you like to extract a hexadecimal value from a string and want to set the last 3 bits to 0 you can do it like this:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
char myHexString[] = "1A";
unsigned char myByte = 0x0;
sscanf(myHexString, "%X", &myByte);
myByte &= 0xF8;
printf("%d, 0x%x\n", myByte, myByte);
return 0;
}
Hope that helps you out.
Walter
-- modified at 7:55 Thursday 2nd March, 2006
|
|
|
|
|
Hello Friends !
I wanna to implement custom recordset (with dynamic fields,i.e. not from any table). Here I can do in VB as below :
'ResponseInfo is an ADODB recordset.
Public ResponseInfo As ADODB.Recordset
Set ResponseInfo = New ADODB.Recordset
Do Until <somecondition_overhere>
ResponseInfo.Fields.Append "FieldName", adVarChar, 250
Loop
ResponseInfo.Open
ResponseInfo.AddNew
'some blaa blaa
ResponseRs.MoveFirst
Do Until ResponseRs.EOF
'some blaa blaa code over here
ResponseRs.MoveNext
Loop
hope so, you've got what I wanna to do. Here I'm just building the recordset with dynamic field definitions, no query/table is used to build the recordset. So, I tried the same in VC++ (using #import "msado15.dll") , but it's not working. The open() requires the parameters, is there any other solution for this, so that i can build the recordset with custom columns (not building rset from any table/database).
Please get me some help...!!!
-Malli...!
|
|
|
|
|
you can specify the SQL query string to _RecordsetPtr after you build the table,like
m_pRecordSet->Open("Select name,caption from users", m_pConnectionString, <br />
adOpenKeyset, adLockOptimistic, adCmdText);
|
|
|
|
|
If we luanch console app from win app with createprocess() it returns immediatly while for example if console app takes several secs to execute can we make createprocess() run in blocking mode that is it should not return until console app terminates??
9ine
|
|
|
|
|
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
CreateProcess(
NULL,
"C:\\Windows\\Notepad.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi );
CloseHandle(pi.hThread);
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
Steve
|
|
|
|
|
Great thanks.
But should we close thread handle before process is terminated?
9ine
|
|
|
|
|
Closing a thread or process handle doesn't terminate the thread or process.
Steve
|
|
|
|
|
The call to WaitForSingleObject takes a handle to the created process. The function waits until the object is signalled which occurs when the process exits so actually it does wait.
|
|
|
|
|
hello...
I am working on VC++ programming.....I want code for getting list of all Services running on computer
Plz help me..
Reply me as early as possible
Thanking You.
Sincerely,
VIRAL PATEL
|
|
|
|
|
Not sure if this is what you need
but a list of services installed can be seen here
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
if u want to get all the runnig process use the Api EnumProcesses()
nave
|
|
|
|
|
|
Hello i have a button if i press the button it should open explorer window and it should not show the D:drive its should be restricted to access.
how can i do that please help me
|
|
|
|
|
sundar_mca wrote: it should not show the D:drive its should be restricted to access.
http://www.codeproject.com/system/SysUtil.asp
"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
|
|
|
|
|
Hi people,
I need some help with IHttpNegotiate interface.
I have a BHO that also implements IBindStatusCallback and IHttpNegotiate interfaces. Also it implements IDispatch interface to catch DWebBrowserEvents2 . So in IDispatch 's Invoke method I create a URLMoniker , as url I pass the url entered in the browser and bind it to my instance of IBindStatusCallback. I was expecting that IHttpNegotiate 's BeginningTransaction method will get called for every request done by browser while loading the given url, I mean for requests to css,jscript,image, etc. but it only gets called for request done for the url itself. Can someone advise how to catch all the requests ?
Thanks.
Here is a bit of code where I create and register the URLMoniker:
<br />
STDMETHODIMP CIEPlugin::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,<br />
DISPPARAMS* pDispParams, VARIANT* pvarResult,<br />
EXCEPINFO* pExcepInfo, UINT* puArgErr)<br />
{ <br />
switch (dispidMember)<br />
{<br />
case DISPID_NAVIGATECOMPLETE2 : <br />
BSTR url;<br />
m_spWebBrowser2->get_LocationURL(&url);<br />
DWebBrowserEvents2 *pstm;<br />
IMoniker* ppmk;<br />
CreateURLMoniker(NULL, url, &ppmk); <br />
IBindCtx *pbc;<br />
CreateAsyncBindCtx(0, this, NULL, &pbc);<br />
RegisterBindStatusCallback(pbc, this, NULL, 0); <br />
ppmk->BindToObject(pbc, NULL, DIID_DWebBrowserEvents2,(void**)&pstm); <br />
break;<br />
default:<br />
break;<br />
}<br />
return S_OK;<br />
}<br />
HRESULT CIEPlugin::BeginningTransaction (LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)<br />
{<br />
MessageBox(NULL, bstr_t(szHeaders), "B", MB_OK);<br />
return S_OK;<br />
}<br />
|
|
|
|
|
Hi All,
when im closing a socket, the windows socket library ASSERTS.
when I debugged the code it is happening byb the following statment at CAsyncSocket::Close function.
"VERIFY(AsyncSelect(0))"
I could not find out the problem. can u help me?
regards
Sarath
Sarath
|
|
|
|
|
I'm trying to use the CWnd::CreateControl method to create an .NET UserControl. Everything is ok until the control (window) is closed.
It seems that it is some reference count problem because the code stops at an ASSERT in the CCmdTarget class.
I provide an example. The client is built in VS 6.0 and the usercontrol is built in .NET 2005.
http://www.codeguru.com/forum/attachment.php?attachmentid=14627
Anyone else that have had the same problem. Please help me with this.
|
|
|
|
|
Hi,
How to convert an array of Hex values to int in Visual C, is there any function for converting?
chaitu
|
|
|
|
|
in what variable do u keep the hex values?????
if ur hex vaue is in some string u can use sscanf to convert it to integer..
nave
|
|
|
|
|
this doesn't mean anything to convert from hexadecimal to int...
hexadecimal IS an integer, but it only differs from the graphical representation...
if you have 32 apples, it is the same as having 0x20 apples...
what you certainly mean however is reading hexadecimal characters from a string (but that is important to know if it is a string or not) into ints... if so, sscanf() is done your you.
otherwise, give more details about what you really have, and what you really want...
cheers,
|
|
|
|
|
It is an array BYTE data[212 Byte], i would like to chanage the hex values saved in the array to int values, as i should decode the polar coordinates from the Hex values saved in the data array.
|
|
|
|