引用指针变量p实现字符串连接函数strcat()的功能

引用指针变量p实现字符串连接函数strcat()的功能

编写程序,通过指针变量p的引用,实现字符串连接函数strcat()的功能。

#include <stdio.h>

int main(int argc, char const *argv[]) {
  char a[2][3] = {"ABC", "DEF"};
  char *p1 = &a[0][3], *p2 = a[1];
  for (int i = 0; i < 3; i++) {
    *p1++ = *p2++;
  }
  *p1 = '\0';
  printf("%s\n",a[0]);
  return 0;
}

陕西科技大学 C语言程序设计课作业 指针-20190327 第二题

猜你喜欢

转载自blog.csdn.net/weixin_44413445/article/details/89951479