반응형

strcpy : string copy

char* strcpy(char *strDestination, const char *strSource)

// strDestination : 복사 당하는 대상
// strSource : 복사할 대상
// return strDestination 포인터
// 
// _CRT_SECURE_NO_WARNINGS 발생하므로 사용 지양, strcpy_s 사용 지향

errno_t strcpy_s(char *dest, rsize_t dest_size, const char *src)

// dest : 복사 당하는 대상
// dest_size : src 메모리 크기
// src : 복사할 대상
// return strDestination 포인터

 

#include <iostream>

using namespace::std;


void string_buf(char* dest, int& size ,char* src)
{
	strcpy_s(dest, size, src);
	cout << "\n\r[INFO] " << dest << endl;
}


int main()
{
	int size = strlen("Hello World");
	size++;

	char* buf = new char[size];

	string_buf(buf, size, (char*)"Hello World");

	delete [] buf;

	return 0;
}
728x90
반응형

+ Recent posts