I see what you mean, I wasn't sure what a hash table was. :( Anyway, thanks. :) I think I can take it from here.
Type: Posts; User: ITAmember
I see what you mean, I wasn't sure what a hash table was. :( Anyway, thanks. :) I think I can take it from here.
Thank you for clearing that up than. :) The keys are not numbers, they are void pointers. So I need a dynamic array not a linked list right?
So what is it than?
Yes you can check if it has the same key, loop through and check keys, if you find a match edit the value instead of adding a new key/value pair.
I'm looking to implement my own hash table system. All keys and values will be the same type. (4 bytes) No shared keys/values, every key must me unique and each key will have it's own value. I was...
32 bit computers have 32 bit registers. If you were to add two 32 bit integers together and the result takes more than 32 bits of space the remainder goes into another register. I don't remember...
Ahh, that's the problem. Works great now, many thanks. :) I shouldn't have any more problems now as arrays are work basically the same as these strings.
Depends, do you have an easier method to implement dynamic typing? This will all be generated code anyway, I'm just trying to figure out how to get it to work.
It at least assigns the data now, I just can't print the whole string. :( New code:
memcpy((void*)((int*)test_str+1), "Hello world!", 13);
printf("the value of test = %s, the type of test =...
Technically I'm assigning an array to a typeless block of memory. :) What I need is just a bulk memory copy function, would memccpy work or is there a better one?
I fail again. :( This time it's with C strings. Important code:
void *test_str = malloc(17);
*(int*)test_str = 3;
*(char*)((int*)test_str+1) = "Hello world!"; /* problem line */
test =...
It works! Working code snippet without the typedef ((void(*)())*((int*)test+1))(); thank you!
Notice the (int*) in ((int*)test+1) casts test to an int to allow the +1 to move the memory address down 32 bits. That (int*) part is just to get the right memory address. Once I get that memory...
Here's the whole code with the relevant code in red
#include <stdio.h>
#include <stdlib.h>
void printer()
{
printf("in printer\n");
}
After some quick changes it does. :) New code
(*((int*)test+1))();
Now I get
error C2064: term does not evaluate to a function taking 0 arguments
Closer, I still don't get what's up with...
((int*)test+1) gets the memory address where the function pointer is stored
EDIT:
BTW I'm trying to call printer.
Can I use that even though I ditched the structs? Regarding the function pointer problem, I have this code
*(*printer)()((int*)test+1);
where printer refers to a function that takes no...
This is a gold mine for FAT32 clicky. just do a google search for "<file system> mbr specifications"
Could you explain how I could use it?
Now I want to call a function pointer using the same method I used on the int and float, here's the relevant code:
void printer()
{
printf("in printer\n");
}
...
void *test_funcptr =...
I realize the shortcommings of my approach. The OP just wanted a faster method without looping through everything. The 3D search would be by far the most flexible and most accurate.
You would have this list of color values:
(0, 0, 0)
(0, 0, 1)
(0, 0, 2)
(0, 0, 3)
(0, 0, 4)
(0, 1, 0)
(0, 1, 1)
I suppose if all the components of your colors were in intervals of, say, 64 you could do simple division. Say your color is (234, 73, 147). you could divide each side by 64 and round to the nearest...
alpha regarding color determines the amount of translucency in the image. kind of like see-through. like the window boarders in vista. 32 bit color depth images have 8 bits for red, green, blue, and...
I rewrote the test program to use malloc and void pointers. This should open up new possibilities. I would like you guys to review the code to see if I made any mistakes however. (don't worry, it...