CJCoding With Joseph
15free / daySign inCreate account

Allocate a Label Through a char ** Out-Parameter

Complete this function (the signature is given and must not change):

void make_label(const char *name, int count, char **out)

It must allocate a new string holding name, then  x , then count — for example bolts and 7 produce bolts x 7 — and store that pointer in *out.

In main, read a word and an integer from input (separated by a space), call make_label, then print two lines: Label:  followed by the string, and Length:  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
Topics:
Pointers
📥 Auto-Input:
bolts 7\n
This input is automatically fed to your program's stdin
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.