C examples for String:String Function
Concatenate one string to another string
#include <stdio.h> /* concatenate t to end of s; s must be big enough */ void strcat(char s[], char t[]){ int i, j;/* w w w . j a v a 2 s . c o m*/ i = j = 0; while (s[i] != '\0') /* find end of s */ i++; while ((s[i++] = t[j++]) != '\0') /* copy t */ ; } int main(){ char buf[1000], urk[1000]; int n = 0; while (fgets(buf, sizeof buf, stdin) != NULL) { sprintf(urk, "%d", ++n); strcat(urk, buf); printf("%s", urk); } return 0; }