|
From: Szentpali J. <ia...@ea...> - 2008-01-07 22:24:31
|
Wobien írta: > &ulRandomNum is the adress of ulRandomNum (You don't give us the > definition of it, so don't know what it is) > (char *) is a cast. It makes the adress of ulRandomNum be read as a > char array. So ((char *) &ulRandomNum) [nIndex] > will give you a byte of the binary code of ulRandomNum. > Wobien > > ----- Original Message ----- From: "Szentpali Janos" <ia...@ea...> > To: <dev...@li...> > Sent: Monday, January 07, 2008 6:32 PM > Subject: [Dev-C++] Translation > > > Hi, > > I am very new to C++. I only did VB programming... mostly. I am having > some trouble with some C++ code. Could someone help me understand what > the following means: > > --- start --- > > typedef DWORD(*FUNCPTR)(BYTE); > > DWORD ulWorkRandomNum; > char *arr; > int nIndex; > > ... > > arr [2 * nIndex] = 'A' + (((char *) &ulRandomNum) [nIndex] & 0x0f); > > --- end --- > > I am having trouble with "translating" (understanding) the > > ((char *) &ulRandomNum) [nIndex] > > part. I mean [nIndex] referes to the elemnt of which array :O > Thanks very much! I knew about the cast and about the address operator, but it somehow seamed strange to cut a pointer in pieces :O. I thought that was the case, but I wasn't sure and I needed assurance :D. Anyway the variable who's address you were talking about is just a DWORD: DWORD ulRandomNum; Sorry I forgot to put it in the sample. -- Szentpáli János |