Is there a way to create a record type equivalent in C like what can be done in TypeScript, and add attributes during runtime?
I am aiming to replicate the following:
const familyData: string[] = ["paul", "em", "matthias", "kevin"];
const myFamily: Record<string, boolean> = {};
familyData.forEach(d => myFamily[d] = true);
Why would I want to do this in C? Well, if I could achieve this, I would be able to quickly determine if Kevin exists or if someone like Gregory doesn't by simply doing this:
const name: string = "kevin";
console.log(familyData["kevin"]);
This approach would save me time when performing calculations.
It's worth noting that in the future, I plan to not only associate a name with a true value but also some additional data.
Currently in C, I am stuck iterating through the entire array to find a person's name, causing the time taken to vary depending on the array size each time I need to access data.
Does anyone have a solution for creating something similar to this in C?
Thank you very much.