Click here to Skip to main content
15,916,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Reading INI sections Pin
David Crow6-Nov-07 7:26
David Crow6-Nov-07 7:26 
Questionapplication priority Pin
RomTibi6-Nov-07 4:25
RomTibi6-Nov-07 4:25 
GeneralRe: application priority Pin
Matthew Faithfull6-Nov-07 4:55
Matthew Faithfull6-Nov-07 4:55 
GeneralRe: application priority Pin
RomTibi8-Nov-07 3:46
RomTibi8-Nov-07 3:46 
AnswerRe: application priority Pin
Randor 6-Nov-07 8:12
professional Randor 6-Nov-07 8:12 
GeneralRe: application priority Pin
RomTibi8-Nov-07 3:47
RomTibi8-Nov-07 3:47 
QuestionDebugging Pin
rrrado6-Nov-07 4:06
rrrado6-Nov-07 4:06 
QuestionHelp understanding C++ data types Pin
mifareman6-Nov-07 3:41
mifareman6-Nov-07 3:41 
Please help! I am a VB/C# developer and just cannot get the following code to work. It is a checksum routine written in C++ and I am recreating it in VB.NET.
I have pretty much everything in place but there is something not right (ie, it isn't working!);

unsigned long check_sum( int file_ptr )
{
unsigned long check_ul = 0L;
unsigned char temp = '0';

CRC_INIT( check_ul );
while( read( file_ptr, &temp, 1 ) > 0 )
{
if( (temp == '\r') || (temp == '\n') || (temp >= '0' && temp <= '9') )
CRC_DATA( check_ul, temp );
}
CRC_STOP( check_ul );
return( check_ul );
}


/*
* NOTE:
* c is unsigned long
* d is unsigned char or char
*/

#define CRC_INIT( c ) c = 0xffffffffL
#define CRC_DATA( c, d ) c = crc_32_tab[ ( int )(((unsigned char)c^(unsigned char)(d)) & 0xff) ] ^ ( c >> 8 )
#define CRC_STOP( c ) c = c ^ 0xffffffffL

unsigned long crc_32_tab[] =
{ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,.. ETC, ETC. (256 items)


The line I think I am struggling on is this one;
#define CRC_DATA( c, d ) c = crc_32_tab[ ( int )(((unsigned char)c^(unsigned char)(d)) & 0xff) ] ^ ( c >> 8 )

This is how I am approaching in VB;


Private Function CRC_DATA(ByVal inChar As Char) As Long
'First extract least significant byte from mCheckSum
Dim b As Byte = mCheckSum And &HFF
'Get the numeric value out of the char passed
Dim c As Byte = Val(inChar)
'Exclusive or the above two
Dim d As Byte = b Xor c
'AND the result with FF
Dim e As Byte = d And &HFF
'e is your indexer. Get the byte from lookup table
Dim f As Long = ChecksumBytes(e)
'Finally, XOR the retireved byte with c shifted 8 bits right
'Dim g As Long = f Xor (mCheckSum >> 8)
Dim g As Long = f Xor (mCheckSum >> 8)
Return g
End Function

Any help would be great
Thanks in advance
Richard
AnswerRe: Help understanding C++ data types Pin
toxcct6-Nov-07 3:54
toxcct6-Nov-07 3:54 
GeneralRe: Help understanding C++ data types Pin
mifareman8-Nov-07 1:03
mifareman8-Nov-07 1:03 
AnswerRe: Help understanding C++ data types Pin
BadKarma6-Nov-07 4:00
BadKarma6-Nov-07 4:00 
GeneralRe: Help understanding C++ data types Pin
mifareman8-Nov-07 1:01
mifareman8-Nov-07 1:01 
GeneralRe: Help understanding C++ data types Pin
BadKarma8-Nov-07 22:50
BadKarma8-Nov-07 22:50 
GeneralRe: Help understanding C++ data types Pin
mifareman9-Nov-07 3:51
mifareman9-Nov-07 3:51 
GeneralRe: Help understanding C++ data types [modified] Pin
BadKarma9-Nov-07 4:46
BadKarma9-Nov-07 4:46 
AnswerRe: Help understanding C++ data types Pin
Nelek6-Nov-07 21:38
protectorNelek6-Nov-07 21:38 
GeneralRe: Help understanding C++ data types Pin
mifareman8-Nov-07 1:05
mifareman8-Nov-07 1:05 
QuestionCan't return the type of <code>_ConnectionPtr*</code> when using ado [modified] Pin
followait6-Nov-07 2:59
followait6-Nov-07 2:59 
AnswerRe: Can't return the type of &quot; _ConnectionPtr* &quot; when using ado Pin
toxcct6-Nov-07 3:12
toxcct6-Nov-07 3:12 
GeneralRe: Can't return the type of &quot; _ConnectionPtr* &quot; when using ado Pin
followait6-Nov-07 3:17
followait6-Nov-07 3:17 
GeneralRe: Can't return the type of &quot; _ConnectionPtr* &quot; when using ado Pin
toxcct6-Nov-07 3:19
toxcct6-Nov-07 3:19 
GeneralRe: Can't return the type of &amp;quot; _ConnectionPtr* &amp;quot; when using ado Pin
followait6-Nov-07 3:29
followait6-Nov-07 3:29 
GeneralRe: Can't return the type of &amp;quot; _ConnectionPtr* &amp;quot; when using ado Pin
rrrado6-Nov-07 4:11
rrrado6-Nov-07 4:11 
GeneralRe: Can't return the type of &amp;quot; _ConnectionPtr* &amp;quot; when using ado Pin
followait6-Nov-07 14:07
followait6-Nov-07 14:07 
GeneralRe: Can't return the type of &amp;quot; _ConnectionPtr* &amp;quot; when using ado Pin
rrrado6-Nov-07 22:18
rrrado6-Nov-07 22:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.