Exercise 9-3. Beginning C, I. Horton

Define a function that will accept an array of pointers to strings as an argument and return a pointer to a string that contains all the strings joined into a single a string, each terminated by a newline character. If an original string in the input array has newline as its last character, the function shouldn’t add another to the string. Write a program to demonstrate this function in operation by reading a number of strings from the keyboard and outputting the resultant combined string.

Solución sin funciones:


Solución con funciones:


Ampliación a cuando el número de strings sea arbitrario (a pointers de pointers):


This entry was posted in C. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s