Prototype
extern Char *strcat (char *dest,char *src);
usage
#include <string.h>
function
Add the string src refers to the end of the dest (cover the ' dest ' at the end of the ending) and add ' the '.
description
The memory regions referred to in SRC and dest cannot overlap and dest must have enough space to hold the SRC string.
Returns a pointer to Dest.
examples
char str4[] = "Hello World";
Char str5[] = "Hello World";
cout << strcat (STR4,STR5) << Endl;
There's going to be a mistake because STR4 don't have enough space
Here is a realization of my own, deficiencies, but also to correct the!!!
Copy Code code as follows:
#include "stdafx.h"
#include <iostream>
#include <assert.h>
using namespace Std;
Connection string
char* Mystrcat (char* deststr,const char* srcstr)//If two strings are the same string?
{
ASSERT (deststr!= null && srcstr!= null);
char* Temp=deststr;
while (*deststr!= ' ")
{
++DESTSTR;
}
while (*deststr++ = *srcstr++)
NULL;
return temp; In order to achieve the chain operation, the destination address is returned
}
int _tmain (int argc, _tchar* argv[])
{
Char str1[25] = "Hello World";
Char str2[] = "Hello World";
cout << Mystrcat (STR1,STR2) << Endl;
return 0;
}