Information About

Strcat




In Computing , the C Programming Language offers a Library Function called strcat that allows one memory block to be appended to another memory block. Both memory blocks are required to be null-terminated. Since, in C, strings are not first-class Datatype s, and are implemented as blocks of ASCII Byte s in memory, strcat will effectively append one string to another given two Pointer s to blocks of allocated memory. The name strcat is an abbreviation of "string concatenate".

For example:

  • str1 = malloc(LARGE_NUMBER_1);

  • str2 = malloc(LARGE_NUMBER_1+LARGE_NUMBER_2-1);


fgets(str1, LARGE_NUMBER_1, stdin);
fgets(str2, LARGE_NUMBER_2, stdin);
  • the argument order makes it like an assignment - str2 "+=" str1 ---/



Here are two possible implementation of strcat:

  • strcat(char ---dest, const char ---src)

  • {

  • orig_dest = dest;

  • (dest++) ); --dest; //dest points at null terminator

  • (dest++) = ---(src++) );

  • return orig_dest;

}



  • dest, const char ---src)

  • {

  • p;

  • q;



EXTERNAL LINKS