Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

Calling all code monkeys!

Thread Tools
 
Old May 3, 2004 | 08:26 PM
  #1  
1stGenCRXer's Avatar
1stGenCRXer
Thread Starter
GWAKS- Tech Geekifier
 
Joined: Oct 2000
Posts: 2,109
Likes: 0
From: Hampton, VA
Default Calling all code monkeys!

I have a bit of a problem with a bloom filter I"m working on, all help would be appreciated, here's the code and errors I'm getting so far:

Originally Posted by code
#include <iostream>
#include <string>

using namespace std;

unsigned long elfhash(char* key)
{
unsigned long h=0,g;
while(*key){
h=(h<<4)+*key++;
if((g=h&0xF0000000L))
h^=g>>24;
h&=~g;
}
return h;
}

int main(void){

int bloom[16];
int h1, h2, h3;
unsigned long h;
char key[15];

while(cin){
cin.get(key);
h = elfhash(key);
h1 = h%15;
h2 = (h%13)+2;
h3 = (h%11)+3;
cout << key << " " << h1 <<","<<h2<<","<<h3;
}
return 0;
}
Originally Posted by errors
[XXXXX@XXXXX final]$ bloom.cpp: In function `int main()':
> bloom.cpp:26: no matching function for call to `std::basic_istream& std::basic_istream::get(_CharT&) [with _CharT = char, _Traits =
-bash: char,: No such file or directory
std::char_traits]
__________________
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
Reply
Old May 4, 2004 | 06:38 AM
  #2  
cowanpp's Avatar
cowanpp
Card carrying badass
 
Joined: Mar 2004
Posts: 768
Likes: 0
From: Little Rock, AR
Default

It seems to be pissed off because it is trying to understand what you want it to do when you are trying to cout the array. I didn't look at the code for very long. Are you trying to cout the values that are in the array or just a specific one? While it does seem weird that it throws an error (I thought it would cout the memory address of the array) I think I can see why it's doing it.
Reply
Old May 4, 2004 | 07:05 AM
  #3  
1stGenCRXer's Avatar
1stGenCRXer
Thread Starter
GWAKS- Tech Geekifier
 
Joined: Oct 2000
Posts: 2,109
Likes: 0
From: Hampton, VA
Default

Thanks for the reply, but I got it fixed, my brain just needed a rest.

The error was coming from trying to pass a string to the function that wanted the values passed as a referenced character array. I just worked some things around and made my cin value a character array and all's well.

The function's job is to convert a string into unsigned long integers to be hashed and stored in a bloom filter. This program just needed to cout the values gotten from hashing on it, to find out which bits are "turned on".

More info on bloom filters.
__________________
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
aphex
The Basement
13
Feb 14, 2004 10:11 PM
nikkim
Integra & 97-01 Integra Type-R
25
Jan 10, 2004 06:28 AM
accordh22
Engine Swaps, Tech & Tuning
11
Dec 31, 2003 04:06 PM
89waggy
CRX & Pre 92 Civic
8
Jul 21, 2003 08:31 AM
muff diver
CRX & Pre 92 Civic
9
May 26, 2003 08:17 PM




All times are GMT -8. The time now is 01:05 PM.