/* concat.c: Paste input strings together */
#include <stdio.h>
#include <string.h>
#define WIDTH 80
#define WRDSIZ 15
main()
{
char buf[WIDTH+1], word[WRDSIZ+1];
int n = 0;
while (gets(word))
{
if (n + strlen(word) > WIDTH)
break;
n += sprintf(buf+n,"%s",word);
puts(buf);
}
return 0;
}
Input:
one
two
three
Output:
one
onetwo
onetwothree
/* End of File */