|
This is something I haven't mastered for some reason.
I am trying to count the number of elements in a one-dimensional array to loop through it so I figured it would be something like sizeof(array) / sizeof(array[0])
Unfortunately this always returns 1. The array consists of 12 longs (but it is empty to begin with and during the calculation. Do different rules apply to empty arrays, and what is the workaround)
Thanks.
|
|
|
|
|
The sizeof trick only works for staticly allocated arrays. It sounds like you're doing something like:
long* ptr = new long[12]; Since the type of ptr is long* , sizeof(ptr) is 4. ptr[0] is a long , and sizeof(long) is also 4. To do what you want, you would have to write:
long arr[12]; Now sizeof(arr) == 12*sizeof(long) == 48.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
I have declared the array staticaly in one function and then passed this empty array in another function (to fill it up) and it is in the second function that sizeof(arr) == 1...I don't understand it!
The function parameter list (2nd one goes something like this)
void(..., ..., long arr[])
{
...
}
|
|
|
|
|
That's because when you pass an array as function parameter, the function always receives a pointer just as if it were declared long* arr . You can't pass an entire array in C.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Right!!!! I forgot about the "call by" rules!!! Thanks.
|
|
|
|
|
Alternatively you could use the Standard Template Library Vector. Which means you don't have to worry about memory allocations or keeping track of sizes of arrays.
// Declare a vector
std::vector<long> data(12);
// Access Elements
data[0] = ...
data.at(0) = ...
// Add element
data.push_back(...);
// Retrieve size of vector
data.size()
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi,
when i m trying to transfer the encoded packet after escape encoding it from client to server using foloowing code snippet.......
AES_EncodeForService(data,key,&res,&len);
// disard <aes_encode> &
strcpy(tempstr,"");
j=0;
for (i=12;i<strlen(res)-13;i++)
{
="" tempstr[j]="res[i];
" j="j+1;
" }
="" ;
="" escape="" encoding...........
="" strcpy(res,"");
="" strcpy(res,tempstr);
="" strcpy(tempstr,"");
="" for="" (i="0;i<strlen(res);i++)
" if="" (="" !(isalnum(res[i])))
="" sprintf(tempchar,"%s%x","%",__toascii(res[i]));
="" else
="" sprintf(tempchar,"%c",res[i]);
="" strcat(tempstr,tempchar);=""
="" combine="" encoded="" with="" tags.....
="" sprintf(withcode,"<aes_encode="">%s",tempstr);
// construct a packet with header followed by footer........
strcpy(packet,header);
strcat(packet,withCode);
// set buffer
len=strlen(packet);
sprintf(sendbuf,"POST /services/ws.asp HTTP/1.0\r\nContent-type: application/x-www-form-urlencoded\r\nContent-length: %d\r\n%s\r\n\r\n",len,packet);
// length of buffer
len=strlen(sendbuf);
// send packet..............
bytesSent = send(ConnectSocket,sendbuf,len,0);
printf("\nBytes Sent: %ld\n\n", bytesSent );
/// receive packet..........
bytesRecv = recv(ConnectSocket,recvbuf,10000,0);
// if doesn't receive the bytes.....
if (bytesRecv <= 0)
printf("\n Error : %d",WSAGetLastError());
// display the received content.........
else
{
printf("\n Receive buffer : %s\n\n",recvbuf);
AES_Decode(recvbuf,key,&recvData,&len);
printf("\n Decode : %s \n\n",recvData);
}
my problem is that the characters which r not aphanumeric get changed and hence does not able to decode it properly.
chirag_a_chauahn
|
|
|
|
|
So what is the problem? Is it the encryption or the data transfer?
Kuphryn
|
|
|
|
|
Okay, so I have this product that modifies a jet database, and now it doesn't work. The program who's database I was modifying switched to MSDE databases. So, I'm assuming that I must do something different programmatically. I just don't know what. Also, I can't even figure out how to create a test MSDE database. I don't even know if it's still a .mdb. Can anyone help?
halblonious
|
|
|
|
|
its not a mdb anymore
its a service running in the background like a proper database
u need to set up an odbc link to it and maybe (this is the horrific part) change ur sql queries cos the syntax is different
msde uses "standard" sql whereas access (jet) didnt
"there is no spoon" biz stuff about me
|
|
|
|
|
Do you have Access? If so, it includes a tool to 'upgrade' your database to SQL Server form. It isn't perfect, but it's a start. In theory, a MSDE database is identical to one made with SQL Server. Try the tool, if you have it, then check the docs on MSDE at MSDN for linking it all together.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
For one, you no longer have MDB files, you have MDF and LDF files. However, these files are not self-contained like the MDBs, so you can't just move them around. It's best to let SQL Server deal with it if you're just starting out.
For two, if you're using DAO to connect to Access, I'd recommend switching to ADO if possible.
For three, to *easily* manage your database, you'll need a replacement for a tool for a program that comes with the real SQL Server called Enterprise Manager. Here's one such replacement...
http://www.webattack.com/get/sqlexecms1.html[^]
And lastly, SQL Server comes with many tools that MSDE does not. One in particular is the DTS wizard and editor. You can run a DTS package with MSDE, but not create one (unless you do everything via code that is).
The last I heard Microsoft was selling SQL Server Developer Edition for only $49. It's way better to develop your DB with the real deal, and then just bring it over to MSDE when you're done.
Jeremy Falcon
|
|
|
|
|
I am trying to put specified windows under active window.
seemslike it doesn't work don't know why.
source is the following
CRect wkRect;
CMyView* pView = (CMyView*)pDoc -> GetView(RUNTIME_CLASS(CMyView) );
CMDIChildWnd * pChildFrm = ( CMDIChildWnd * ) pView -> GetParentFrame();
pChildFrm ->GetWindowRect( wkRect );
::SetWindowPos( CMDIChildWnd ->m_hWnd, &wndNoTopMost, Pos.x, Pos.y, wkRect.Width(), wkRect.Height(), SWP_SHOWWINDOW);
I have 2 view 1 doc mdi application i want to bring the other behind the window when one of views is activated. what is problem with my source.
Any help is appreciated!
thanks & have a nice weekend to all of you.
Shin
|
|
|
|
|
I am still seeking for the answer.
Shin
|
|
|
|
|
Hello all
I want to program an application which has to retrieve info reg whether the browser is using the proxyserver or not. I found this information in registry under
HKEY_USERS\S-1-5-21-1614895754-1647877149-839522115-500\Software\Microsoft\Windows\CurrentVersion\Internet Settings
But I would like to know whether this works on all windows machines or not. If there's any better way of retreiving this information, pls suggest.
Thanks for your help.
Hari.
|
|
|
|
|
Hi,
Do you want to do that programatically ? HKEY_USERS info is user based. You will find similar such settings under HKEY_LOCAL_MACHINE too.
-Sudha
|
|
|
|
|
Thanks for the reply. I found similar settings in HKEY_USERS.
Hari.
|
|
|
|
|
Ok, I know how to use the GetPixel function, the only problem is that I must get the DC of an inactive/minimized window. I've tried HDC hdc = ::GetWindowDC(hwnd) , HDC hdc = ::GetDC(hwnd) , HDC hdc = ::LockWindowUpdate(hwnd) , but all of them returns -1 when I call the GetPixel function on any pixel of that DC.
If I can figure this out, it would GREATLY help my project.
Thanks a lot in advance
~Mike
|
|
|
|
|
You can't get pixels from a minimized window. There is no "canvas".
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
So in no way I can do this?
Damn, that sucks. With this, my project would have been so great...
|
|
|
|
|
Not to my knowledge, no. The device context mirrors what's shown on screen. If there's nothing on screen, then there are no pixels to grab.
This window you're trying to snatch pixels from.. is it in the same process as your pixel grabbing routine? If it is, you could always make the "source window" double buffered. That is, it keeps a bitmap of itself internally. That way you could access the bitmap for pixels. Otherwise it's a pretty tough job I reckon.
By the way, after GetPixel() returns -1, have you checked the error code? Either call GetLastError() or add the @err pseudo-variable in the watch window in the debugger.
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
Well, I have a game window opened and minimized, I'm using ::FindWindow to get its HWND value, I tried all possible ways to get the window's DC, but couldn't.
Would it be possible to get a bitmap or a BitBlt and get the pixel I want from it? If so, how could I do it?
Thanks a lot for your help
~Mike
|
|
|
|
|
i think u can send it a wm_paint message and pass a dc in
then it draws to that dc
and u can grab what u like
"there is no spoon" biz stuff about me
|
|
|
|
|
Uh? Pass a DC in a WM_PAINT message?
How do you do that?
I doubt it's possible...
~Mike
|
|
|
|
|