1. 首页
  2. 数据库
  3. 其它
  4. 串数组习题:实现下面函数的功能。函数void insert(char*schar*tint pos)将字符串t插入到字符串s中插入位置为pos。假设分配给字符串

串数组习题:实现下面函数的功能。函数void insert(char*schar*tint pos)将字符串t插入到字符串s中插入位置为pos。假设分配给字符串

上传者: 2021-02-27 12:29:55上传 PDF文件 31.92KB 热度 171次
此代码可以正常运行 #include #include // 第一种插入方式, 先把s的pos以后的字符串链接到t上,然后在将t插入到s的pos位置 void insert(char *s, char *t, int pos) { char *p=s, *q = t; int i = 0, lent = 0; if(pos<1) { printf(位置不合理\n); exit(0); } while(*p&&i<pos-1) { p++; i++; } if(*p=='\0') { printf(位置不合理\n); exit(0);
下载地址
用户评论