Comparing structs
Në shqip: Krahasimi i struct-eve
ShpjegimiSQ
Në C s'mund t'i krahasosh dy struct-e me ==. Duhet t'i krahasosh fushë pas fushe. memcmp() duket si zgjidhje, por gabon nëse ka padding ose tekste me pointer.
EnglishEN
In C you can't compare two structs with ==. You have to compare them field by field. memcmp() looks like a fix, but fails with padding or string pointers.
Si ta mendosh
Si t'i krahasosh dy formularë kuti pas kutie.
Lexoje në anglisht
Like comparing two forms box by box.
Shembull kodic
int te_barabarte(struct Pika a, struct Pika b) {
return a.x == b.x && a.y == b.y;
}