现在的位置: 首页 > 综合 > 正文

memcpy(str2,str1,i);

2013年05月27日 ⁄ 综合 ⁄ 共 299字 ⁄ 字号 评论关闭
// memcpstr.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "string.h"

int main(int argc, char* argv[])
{
	char str1[100]="BCD";
	char str2[100]="AAAAAAAA";
	int i=0;
	for(i=1;i<=4;i++)
	{
		memcpy(str2,str1,i);
		printf("%s\n",str2);
	}
	
	return 0;
}
/*
BAAAAAAA
BCAAAAAA
BCDAAAAA
BCD
Press any key to continue
*/

抱歉!评论已关闭.