Path C vs. C ++

So I need to write a program that will iterate over the image and record the pixel positions corresponding to each color pixel that appears in it. For example, given

http://www.socuteurl.com/fishywishykissy

I need to find the coordinates of all yellow, purple, dark pink, etc. pixels.

In C ++, I would use a hash table for this. I would iterate over the image, check each pixel value, look for this value and add the coordinates of the pixel to the vector if it was found, or add a new record to the table if there was no value.

The problem is that I may need to write this program in pure C instead of C ++. How will I do this in C? I feel that the implementation of the hash table will be rather unpleasant and error prone: should I not do this?

I'm pretty inexperienced with C and have a lot of C ++ experience if that matters.

Thank.

+3
source share
7 answers

There is no algorithm / datastructure that you can implement in C ++ that cannot be implemented in C. Sometimes it is perhaps more elegant in C ++, but it is never impossible in C.

Here are some implementations of C hash tables: http://www.google.ca/search?q=hash+table+c

You may also be interested in this OOP in the C vs C ++ link: http://www.eventhelix.com/realtimemantra/basics/object_oriented_programming_in_c.htm

In general, if you use classes in C ++, you can use structs + functions in C.

+6
source

, , .

, . (R, G, B) (R, G, B, X, Y) .

qsort . .

+6

uthash, -. struct /, .

HashTable C, .

+1

- C.

, ?

0

search.h , . , .

: man hsearch man tsearch

0

SO C, :

0

.

, . . (, (-1, -1)). . . .

, .

( , , , ).

0

Source: https://habr.com/ru/post/1749223/


All Articles