分析下列程序输出

#include<iostream>
#include<string.h>
using namespace std;
int main() {
char p1[]="abcd",*p2="ABCD",str[]="xyz";
strcpy(str+,strcat(p1+,p2+));
cout<<str;
return ;
}

程序输出xycdBCD

分析:

strcat(p1+2,p2+1); //返回以p1+2为首的字符串,即"cdBCD" 
strcpy(str+2,strcat(p1+2,p2+1)); //将"cdBCD"copy到str+2位置上,并覆盖后面的内容,此时str为"xycdBCD" 

1strcat/strcpy应用的更多相关文章

  1. strcpy函数在VS2015无法使用的问题

    一:原因:一般认为是vs准备弃用strcpy的,安全性较低,所以微软提供了strcpy_s来代替 然而,strcpy_s并没有strcpy好用,我们要想继续在VS2015中使用strcpy该怎么办 呢 ...

  2. 你必须知道的指针基础-4.sizeof计算数组长度与strcpy的安全性问题

    一.使用sizeof计算数组长度 1.1 sizeof的基本使用 如果在作用域内,变量以数组形式声明,则可以使用sizeof求数组大小,下面一段代码展示了如何使用sizeof: ,,,,,}; int ...

  3. strcpy 函数的实现

    原型声明:extern char *strcpy(char *dest,const char *src); 头文件:string.h   功能:把从src地址开始且含有‘\0’结束符的字符串赋值到以d ...

  4. Linux C 字符串函数 strlen()、strcat()、strncat()、strcmp()、strncmp()、strcpy()、strncpy() 详解

      strlen(返回字符串长度) 表头文件 #include <string.h> 定义函数 size_t strlen(const char *s); 函数说明 strlen()用来计 ...

  5. strncpy,strcpy

    strncpy不会为des自动添加“\0” strcpy遇空结束,自动添加结束符 结论: 1.使用strcpy时一定不能用于无结束符的字符串,因为strcpy依赖\0判断源字符串的结束 2.使用str ...

  6. strcpy strlen memcpy等的函数实现

    #include <assert.h> #include <string.h> #include <stdlib.h> #include <stdio.h&g ...

  7. 字符串strcpy

    strcpy函数的表达方式: //把一个char组成的字符串循环右移n个,如:“abcdefghi",n=2,移动后"hiabcdefgh" #include <i ...

  8. strlen(); strcpy(); strcat(); strcmp() ---笔记

    指针小知识点: int a =10; int *p=&a; int *q=p;        //p中保存的是a的地址 int *q=p;       //将p的值赋给q 作用是让q也指向a ...

  9. strcpy 库函数 拷贝函数

    strcpy 是在string.h 里面 #include "stdafx.h"#include "string.h"struct Student{int Se ...

随机推荐

  1. C#调用非托管dll

    以C#开发周立功CAN举例,在官网下载了周立功的demo 一.C++头文件样子 //接口卡类型定义#define VCI_PCI5121 1 //一些结构体定义 typedef struct tagR ...

  2. script 加载顺序问题的延展研究

    今天群里有人问为什么会出现脚本的加载顺序与定义脚本顺序不一致的问题,这个问题引起了我的好奇,经过一番调研,有了这篇文章. 这是一个伪命题吗? 首先,W3C 推荐 script 脚本应该被立即加载和执行 ...

  3. Python3基础 if elif 示例 判断一个数在哪个区间内

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  4. IE6里样式表不起作用解决方法

    写的html页面引用外部css文件的时候在IE7,IE8和FF中能正常作用,即能正常显示,可在IE6中却完全没有作用到,即css文件里的样式根本未被解析到我们的html页面,这是什么原因? 开 始把c ...

  5. excel依赖的dll

    依赖的先后顺序 stdole.dll office.dll Microsoft.Vbe.Interop.dll Microsoft.Office.Interop.Excel.dll Interop是i ...

  6. 封装TeeChart控件

    public class MyChart { //字段 private TChart tChart; /// <summary> /// 构造函数,默认不是3D效果 /// </su ...

  7. [SpringBoot] - 上线一份项目记录

    首先在服务器上运行war包. (新建项目) 其后,选择数据库,因为之前感觉mysql比较难安装,这次就再试一次,之前的PostgreSQL没有问题. 将原有文件进行复制,排除导包错误. 首先测试邮件发 ...

  8. Codeforces Beta Round #94 div2 D 优先队列

    B. String time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  9. shell 求模

    $ expr % $ let i=% $ echo $i $ echo % | bc $ ((i=%)) $ echo $i

  10. c++ 查找数组或者容器元素是否存在(find)

    #include <iostream> // cout #include <algorithm> // find #include <vector> // vect ...