#include <stdio.h>
#include <string.h>
typedef struct {
int id;
char name[20];
} RubyObject;
RubyObject findObjectByAttribute(RubyObject arr[], int size, char *attr) {
for (int i = 0; i < size; i++) {
if (strcmp(arr[i].name, attr) == 0) {
return arr[i];
}
}
RubyObject notFound = { -1, "" };
return notFound;
}
int main() {
RubyObject objects[] = {
{ 1, "Ruby1" },
{ 2, "Ruby2" },
{ 3, "Ruby3" },
};
RubyObject result = findObjectByAttribute(objects, 3, "Ruby2");
if (result.id != -1) {
printf("Object found: %d, %s\n", result.id, result.name);
} else {
printf("Object not found\n");
}
return 0;
}