#Dictionaries

9 messages · Page 1 of 1 (latest)

cerulean zodiac
#

I need help with creating a function that take two dictionaries as the input. It will look at the starting indexes for both and create an array that's size is equal to both dictionaries combined. then it will place the contents of dictionary 1 and 2 onto this new array sorted. the dictionaries each contain a few strings of food as elements. dict 1 has "apple, banana, orange" and 2 has "car, truck, bus". I have created the dicts using structs as such

struct mystruct {
char key[20];
char content[20];
int count;
};

where each element in the dict has a key and a content value. we also have a count but i dont know if we need it. Ive tried a few things but most of them not only give error, but have fault in the logic, aka i didnt know where i was going with it.

elfin thistleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

hallow ledge
#

What kind of dictionaries? How did you create the dictionaries? What kind of array? And why?

#

The struct that you've created doesn't explain almost anything, why is it 20? Why is it named my struct?

#

Why is the count stored there as well?

#

Do you actually need a dictionary, aka map, or just arrays?

cerulean zodiac
#

First of all, i made a mistake by writing in this forum as Im trying to do this in C, not C++. For that im truly sorry. By dictionaries, i meant more of an array where each element has a key and a value. I have put 20 in as the max amount of char as kind of a place holder as the words in thr arrays are less than 20 char. Im a novice when it comes to C and during the initial stage of programming, i like to bame structs by something like mystruct so that when looking back, i can easily tell what is being used where.

#

Ill try asking in the C channel with a more concise prompt. Thank you for your time

#

!solved