指针 插入字符串
题目:用指针实现以下功能,输入两个字符串a和b,在字符串a指定的位置n的后面插入字符串b.(对于算法有点懵)
#include <stdio.h> #include <memory.h> int main(int argc, char** argv) { char cTmp1[100] = ""; char cTmp2[100] = ""; char cTmp3[200] = ""; int n = 0; scanf("%s %s %d", cTmp1, cTmp2, &n); memcpy(cTmp3, cTmp1, n); memcpy(cTmp3+strlen(cTmp3), cTmp2, strlen(cTmp2)); memcpy(cTmp3+strlen(cTmp3), cTmp1+n, strlen(cTmp1) - n); printf("cTmp3:%s\n", cTmp3); }