← Back to Pointers
Question 462
Allocate a Label Through a char ** Out-Parameter
Allocate a Label Through a char ** Out-Parameter
Complete this function (the signature is given and must not change): voidmake_label(const char *name, int count, char **out)It must allocate a new string holdingname, thenx, thencount— for exampleboltsand7producebolts x 7— and store that pointer in*out. Inmain, read a word and an integer from input (separated by a space), callmake_label, then print two lines:Label:followed by the string, andLength:followed by the number of characters in that string. For the input: bolts 7 the output is exactly what is shown in Expected Output. Each line ends with a newline. The word is never longer than 31 characters. Free the memory you allocate before the program ends — this question checks for memory leaks.
Expected Output:
Label: bolts x 7 Length: 9
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.