![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
You must measure the length of the
string lying in the input_buffer
array so that you can reserve just the right number of bytes. To measure
the length of a string, such as a trade-describing string, you can use a
function supplied by C's string-handling library, which you announce your
intention to use through the following
declaration:
#include
The string-handling function you need is strlen
for string
length:
strlen (input_buffer)
Because strlen
returns the number of characters in a string, you
need to add 1, to account for the null character, when you allocate space
for a new array:
malloc (strlen (input_buffer) + 1)