Sponsored Content
Full Discussion: C++ to C
Top Forums Programming C++ to C Post 302397367 by Corona688 on Monday 22nd of February 2010 01:46:27 AM
Old 02-22-2010
As usual, I can't see your code from here so can't tell why it's segmentation faulting. if I had to guess, I'd guess you were feeding integers into crc_add instead of pointers to integers.

Code:
// For integers, objects, etc 
crc_add(&crc, &object, sizeof(object));
// for arrays
crc_add(&crc, array, sizeof(array));
// for a pointer
crc_add(&crc, pointer, sizeof(*pointer));
// for a string
crc_add(&crc, string, strlen(string));

This is all from basic understanding of pointers in the C language.
 
Digest::CRC(3)						User Contributed Perl Documentation					    Digest::CRC(3)

NAME
Digest::CRC - Generic CRC functions SYNOPSIS
# Functional style use Digest::CRC qw(crc64 crc32 crc16 crcccitt crc crc8 crcopenpgparmor); $crc = crc64("123456789"); $crc = crc32("123456789"); $crc = crc16("123456789"); $crc = crcccitt("123456789"); $crc = crc8("123456789"); $crc = crcopenpgparmor("123456789"); $crc = crc($input,$width,$init,$xorout,$refout,$poly,$refin,$cont); # add data to existing $crc = crc32("ABCD", $crc); # OO style use Digest::CRC; $ctx = Digest::CRC->new(type=>"crc16"); $ctx = Digest::CRC->new(width=>16, init=>0x2345, xorout=>0x0000, refout=>1, poly=>0x8005, refin=>1, cont=>1); $ctx->add($data); $ctx->addfile(*FILE); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest; DESCRIPTION
The Digest::CRC module calculates CRC sums of all sorts. It contains wrapper functions with the correct parameters for CRC-CCITT, CRC-16, CRC-32 and CRC-64, as well as the CRC used in OpenPGP's ASCII-armored checksum. SEE ALSO
https://tools.ietf.org/html/rfc4880#section-6 AUTHOR
Oliver Maul, oli@42.nu COPYRIGHT
CRC algorithm code taken from "A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS". The author of this package disclaims all copyrights and releases it into the public domain. perl v5.18.2 2017-10-06 Digest::CRC(3)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy