網(wǎng)站開發(fā)有哪些要求鄭州seo優(yōu)化阿亮
C程序設(shè)計語言 (第二版) 練習(xí) 5-3
練習(xí) 5-3 用指針方式實現(xiàn)第2章中的函數(shù)strcat。函數(shù)strcat(s, t)將t指向的字符串復(fù)制到s指向的字符串的尾部。
注意:代碼在win32控制臺運行,在不同的IDE環(huán)境下,有部分可能需要變更。
IDE工具:Visual Studio 2010
?
代碼塊:
#include <stdio.h>
#include <stdlib.h>void strcat(char *s, char *t){int i, j;for(i = 0; s[i] != '\0'; i++);for(j = 0; (s[i++] = t[j++]) != '\0';);
}int main(){char s[30] = "hello ";char t[] = "world!";strcat(s, t);printf("%s\n", s);system("pause");return 0;
}