分析下列程序输出

#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. poj 2777 Count Color - 线段树 - 位运算优化

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42472   Accepted: 12850 Description Cho ...

  2. 在linux桌面上显示图标

    把应用程序的图标添加到桌面上 左图显示了把应用程序的图标添加到桌面上的两种方法,哪种更好看? 想要把应用程序图标添加到桌面上,请先确保已设置了在桌面上显示图标,方法是: 1.安装gnome-tweak ...

  3. loj 诗歌

    链接 链接 思路 好久之前的考试题了吧,之前貌似抄的题解 现在理解了怕忘了,就写个题解记录一下吧,题目还是不错的 枚举中间点j \[H_{i}-H_{j}=H_{j}-H_{k}\] \[H_{k}+ ...

  4. 每个成长者,必须学会可以练习 (来自ProcessOn流程图工具作者底部)

  5. c语言 数组合并

    #include<stdio.h> int main() { int m,n,i,j,k; printf("Enter no. of elements in array1:\n& ...

  6. Selenium 对元素element的操作举例

    前三个用的比较多,模拟用户操作最多的就是点击,输入文本,其他的UI自动化测试中涉及的不多,对判断元素是否存在,断言元素是否被选中,元素被选中后CSS属性是否更改等,还是很有必要的.

  7. DataTable转化成实体对象

    /// <summary> /// The data extension. /// </summary> public static class DataExtension { ...

  8. MongoDB(课时13 where条件过滤)

    3.4.2.8 条件过滤 关系型数据库开发对于数据的筛选,想到的一定是where语句,MongoDB里面提供的是"$where". 范例:使用where进行数据的查询 db.stu ...

  9. Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'as3'

    执行更新时的出错信息 Whitelabel Error Page This application has no explicit mapping for /error, so you are see ...

  10. Use a layout_width of 0dip instead of fill_parent for better performance

    安装了最新的ATD 18之后,新加的Lint Warnings插件会给我们检测出许多xml布局中不当的地方,例如: Use a layout_width of 0dip instead of fill ...