您的位置:首页 > 其它

StrCat <shlwapi.h> strcat <string.h> wcscat <string.h>

2012-06-28 15:33 603 查看
StrCat Function

--------------------------------------------------------------------------------

Appends one string to another.

Syntax

LPTSTR StrCat( LPTSTR psz1,

LPCTSTR psz2

);

Parameters

psz1

[in, out] Pointer to a null-terminated string to which the function appends psz2. This buffer must be large enough to hold both strings
and the null terminator.

psz2

[in] Pointer to a null-terminated string to be appended to psz1.

Return Value

Returns a pointer to psz1, which holds the combined strings.

Remarks

Security Alert Using this function incorrectly can compromise the security of your application. The first argument, psz1, must be large
enough to hold psz2 and the closing '\0 ', otherwise a buffer overrun may occur. Buffer overruns may lead to a denial of service attack against the application if an access violation occurs.
In the worst case, a buffer overrun may allow an attacker to inject executable code into your process, especially if psz1 is a stack-based buffer. Consider using one of the following alternatives:
StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, or StringCchCatNEx. You should review Security Considerations: Microsoft Windows Shell before continuing.

Function Information

Minimum DLL Version shlwapi.dll version 4.71 or later

Custom Implementation No

Header shlwapi.h

Import library shlwapi.lib

Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0

--------------------------------------------------------------------------------

© 2003 Microsoft Corporation. All rights reserved.

==================================================================================

Microsoft C Run-Time Library for Windows CE .NET

strcat, wcscatSee Also

strncat, strncmp, strncpy

Append a string.

Routine Required Header

strcat <string.h>

wcscat <string.h>

char *strcat( char *strDestination, const char *strSource );

wchar_t *wcscat( wchar_t *strDestination, const wchar_t *strSource );

Parameters

strDestination

Null-terminated destination string

strSource

Null-terminated source string

Libraries

All versions of the C run-time libraries.

Return Value

Each of these functions returns the destination string (strDestination). No return value is reserved to indicate an error.

Remarks

The strcat function appends strSource to strDestination and terminates the resulting string with a null character. The initial character
of strSource overwrites the terminating null character of strDestination. No overflow checking is performed when strings are copied or appended. The behavior of strcat is undefined if the source and
destination strings overlap.

wcscat is the wide-character version of strcat. The arguments and return value of wcscat are wide-character strings. These two functions
behave identically otherwise.

Security Remarks

The first argument, strDestination, must be large enough to hold the current strDestination and strSource combined and a closing '\0 ';
otherwise, a buffer overrun can occur. This may lead to a denial of service attack against the application if an access violation occurs, or in the worst case, allow an attacker to inject
executable code into your process. This is especially true if strDestination is a stack-based buffer. Consider using strncat or wcsncat

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE Defined

_tcscat wcscat

Example

/* STRCPY.C: This program uses strcpy

* and strcat to build a phrase.

*/

#include <string.h>

#include <stdio.h>

void main( void )

{

char string[80];

strcpy( string, "Hello world from " );

strcat( string, "strcpy " );

strcat( string, "and " );

strcat( string, "strcat! " );

printf( "String = %s\n ", string );

}

Output

String = Hello world from strcpy and strcat!

See Also

strncat, strncmp, strncpy

--------------------------------------------------------------------------------

Send feedback on this topic to Microsoft

© Microsoft Corporation. All rights reserved.

Topic Version 7.1.2277.1013
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: