기본 c 헤더파일 include
#inclued <stdio.h>
c++에서 include
#include <cstdio>
.h
를 생략하고 앞에 c
를 붙이면 c언어와 대응되는 c++헤더파일이 include된다.
- 모든 표준함수들이 namespace std안에 선언되어있다.
- c언어에 없던 오버로딩이 추가되어있다.
string 관련
#include <cstring>
int main()
{
char string[20] = "Hellow";
char plus[10] = "World";
int len = std::strlen(string);
std::strcat(string, plus);
std::cout << string;
std::strcpy(string, plus);
std::cout << string;
}
random
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
srand(time(NULL));
for(int i=0; i<10; i++)
cout << rand%100;
}