Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write the following functions: Part 2 : An Emoji Translator For the second part of this MP you will create a emoji translation utility. Unlike
Write the following functions:
Part : An Emoji Translator
For the second part of this MP you will create a emoji translation utility. Unlike emojiinvertChar, these translations might change the length of the string, meaning youll need to impement some kind of data structures to support the translation.
In emojitranslate.c you will find four functions:
void emojiinitemojit emoji is called to initialize an emoji object.
void emojiaddtranslationemojit emoji const unsigned char source const unsigned char translation adds a translation to the emoji object. For example, might translate to diamond.
const unsigned char emojitranslatefileallocemojit emoji const char fileName must translate the contents of the file specified by fileName using all translation rules added so far. When matching rules, always choose the longest matching rule based on the length of the source.
For example, if only one rule diamond has been added: s are forever!" would translate to "diamonds are forever!".
If the rule diamond and Bejeweled, with s would translate to "Bejeweled with diamonds", not "diamonddiamonddiamond with diamnds" since the rule using three emoji is the longer than the one with one emoji.
void emojidestroyemojit emoji is called to destroy the emoji object and any memory allocated by your emoji library.
Example Usage
emojit emoji;
emojiinit&emoji;
emojiaddtranslation&emoji, "heart";
The file on disk contains: "I Illinois!"
unsigned char translation emojitranslatefilealloc&emoji, "teststxtsimpletxt;
Translation Output: "I heart Illinois!"
printfs
;
emojidestroy&emoji;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started