strcpy函数细节
来源:互联网 发布:宾馆住宿客房软件 编辑:程序博客网 时间:2024/06/05 06:00
char * strcpy(char *dest,char *sour);
c = strcpy(a,b)
a只能是空间足够大的字符串数据对象,比如说数组。a的空间不够大,将导致越界,不产生异常,但修改相临存储区的内容。
b可以是指向字符串的指针或字符串数组,也可以是字符串常量。
c可以是指向字符串的指针或字符串常量。
strcpy的高级用法:
#include<stdio.h>
#include<string.h>
int main()...{
char *orig = "beast";
char *ps;
char copy[40] = "be the best that you can be";
puts(orig);
puts(copy);
ps= strcpy(copy+7,orig);
puts(copy);
puts(ps);
getchar();
return 0;
}
#include<string.h>
int main()...{
char *orig = "beast";
char *ps;
char copy[40] = "be the best that you can be";
puts(orig);
puts(copy);
ps= strcpy(copy+7,orig);
puts(copy);
puts(ps);
getchar();
return 0;
}
结果是:beast
be the best you can be
be the beasat
beast
另外:strcpy()不检查目标字符川是否能容纳下源字符串,解决的办法是尽量分配大的空间,或者用strncpy()
- strcpy函数细节
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy()函数
- strcpy() 函数
- strcpy函数
- strcpy函数
- Strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数 .
- strcpy函数
- strcpy函数
- strcpy 函数
- 重新开始写blog
- 你真的会用Google搜索引擎吗(二)
- Rails for Eclipse(转载)
- MySQL下使一个字段自增
- SQL Server定期自动备份
- strcpy函数细节
- ArcGIS 9.2 Server Enterprise for Windows的安装与开发环境搭建
- asp.net 2.0 GridView导出数据到Excel
- 水晶报表向参数字段传递参数
- prototype对于标签定位的一些BUG [摘]
- Oracle/Sqlserver/MySQL三种数据库选取第m至第n行记录(zt)
- asp.net 2.0防止同一用户同时登陆
- 删除数据库中重复数据的几个方法 (ZT)
- Use Ibatis to manage ORACLE database!