문자열 - 문자배열
reference
실습 예제
ch04ex2_stringcat.cpp
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void stringcat(char* p_str1, const char* p_str2);
int main()
{
char str1[20] = "Hello";
char str2[10] = "world";
stringcat(str1, str2);
cout << "str1: " << str1 << endl;
return 0;
}
void stringcat(char* p_str1, const char* p_str2)
{
int idx = 0;
for (int i = 0; p_str1[i] != '\0'; i++, idx++);
for (int i = 0; p_str2[i] != '\0'; i++)
{
p_str1[idx++] = p_str2[i];
}
p_str1[idx] = '\0';
}ch04ex3_stringswap.cpp
실습 문제
ch04lab3_stringadd.cpp
Last updated