Mega Code Archive
Join array of strings into a single string
/*
Beginning C, Third Edition
By Ivor Horton
ISBN: 1-59059-253-0
Published: Apr 2004
Publisher: apress
*/
#include
#include
#include
#include
#define MAX_STRINGS 100 /* Maximum string count */
#define BUFFER_SIZE 50 /* Initial input buffer size */
char* join_strings(char *strings[], int count); /* Joins array of strings into a single string */
char* read_string(); /* Reads a string from the keyboard */
void main()
{
char *pStrings[MAX_STRINGS]; /* Array of pointers to strings */
char *joined_strings = NULL; /* Pointer to the joined string */
int count = 0; /* Number of strings entered */
char answer = 'y'; /* Confirms more input */
char terminator = '*'; /* Terminator for string entry */
int i = 0;
/* Read the strings */
while(count