etc./열혈 C++ 프로그래밍

(열혈 C++ 프로그래밍) 문제 02-4

innit 2021. 11. 11. 15:38

C++의 표준함수 호출

 

 

 

 

 

 

 

문제1

#include <iostream>
#include <cstring>
using namespace std;

int main(void)
{
	char tmp1[10] = "abcde";
	char tmp2[10] = "fgha";

	cout << strlen(tmp1) << endl;
	strcat(tmp1, tmp2);
	cout << tmp1 << endl;
	strcpy(tmp1, tmp2);
	cout << tmp1 << endl;
	cout << strcmp(tmp1, tmp2) << endl;

	return 0;
}

문제2

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main(void)
{
	srand(time(NULL));
	for (int i = 0; i < 5; i++) {
		int x = rand() % 100;
		cout << x << endl;
	}

	return 0;
}

 

 

 

 

728x90
반응형