converting a simple file from C to C++

I was wondering how you would convert the following source code (which compiles in C) to a C++ file. It's a simple CRC calculator and the very first line of code seems to have issues, thanks for your help!:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
This function calculates the CRC used by the "Modem Protocol"
The first argument is a pointer to the message block. The second
argument is the number of bytes in the message block. The message
block used by the Modem Protocol contains 128 bytes.
The function return value is an integer which contains the CRC. The
lo order 16 bits of this integer are the coefficients of the CRC. The
The lo order bit is the lo order coefficient of the CRC.
*/

int calcrc(ptr, count) char *ptr; int count; {

int crc, i;

crc = 0;
while(--count >= 0) {
crc = crc ^ (int)*ptr++ << 8;
for(i = 0; i < 8; ++i)
if(crc & 0x8000)
crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
}
return (crc & 0xFFFF);
}
Just change the first line for:
 
int calcrc (char* ptr, int count) {

Topic archived. No new replies allowed.