lstrcat實現

編寫函數_lstrcat。說明如下:
實現Windows 系統函數lstrcat 的功能:將一個字符串拼接到另一個字符串的未尾。
char* _lstrcat(char* lpszDest, const char* lpszSrc);
說明:
(1) 關於lstrcat 的說明可查閱MSDN。
(2) 必須自行實現相關功能,不得直接調用lstrcat 之類的系統函數或庫函數。 

 

#include <iostream.h>

char* _lstrcat(char* dst, const char* src)
{
    
char * cp = dst; 
    
while(*cp) 
        cp
++;                   /* find end of dst */ 
    
while*cp++ = *src++ ) ;   /* Copy src to end of dst */ 
    
return( dst );              /* return dst */ 
}


void main()
{
    
char a[100= "hello"
    
char b[7= " world";
    
char *= _lstrcat(a,b);
    
int i=0;
    
while(a[i] != '
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章