社区
C语言
帖子详情
strcpy该怎么用
lingkeylbh
2007-03-09 08:20:53
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char *dst,*src;
src = "hello,strcpy";
strcpy(dst,src);
//dst = src;
printf("%s %s\n",src,dst);
system("PAUSE");
return 0;
}
我不知道哪里错了,谁指点一下啊
...全文
243
3
打赏
收藏
strcpy该怎么用
#include #include #include int main(int argc, char *argv[]) { char *dst,*src; src = "hello,strcpy"; strcpy(dst,src); //dst = src; printf("%s %s\n",src,dst); system("PAUSE"); return 0; } 我不知道哪里错了,谁指点一下啊
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
todototry
2007-03-09
打赏
举报
回复
strcpy(dst,src);
================
dst指针所指向的内存段需足够尺寸存放src字符串,需分配好内存,数组堆内存
iamcaicainiao
2007-03-09
打赏
举报
回复
//或者这样。
#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char *argv[])
{
char *dst,*src;
dst = new char(strlen(src)+1);
src = "hello,strcpy";
strcpy(dst,src);
//dst = src;
printf("%s %s\n",src,dst);
system("PAUSE");
return EXIT_SUCCESS;
}
DonaldKnuth
2007-03-09
打赏
举报
回复
//你的dst没有分配内存
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char dst[20], *src;
src = "hello,strcpy";
strcpy(dst,src);
printf("%s %s\n",src,dst);
system("PAUSE");
return 0;
}
memcpy和
strcpy
源码
网上参考资料写的memcpy以及
strcpy
的源码,希望能帮助大家。
编写_
strcpy
函数
编写_
strcpy
函数 函数原型 char* _
strcpy
(char *strDest, const char *strSrc)
C语言程序设计-用函数实现字符串的复制, 不允许用
strcpy
()函数.c
C语言程序设计-用函数实现字符串的复制, 不允许用
strcpy
()函数.c
编写
strcpy
函数
编写
strcpy
函数
实现
strcpy
实现
strcpy
,
strcpy
的功能的实现原理
C语言
70,023
社区成员
243,263
社区内容
发帖
与我相关
我的任务
C语言
C语言相关问题讨论
复制链接
扫一扫
分享
社区描述
C语言相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章