C++ Chapter 02. C언어 기반의 C++ 2. 


02-6 C++에서 C언어의 표준함수 호출하기


* c를 더하고 .h 빼라

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <cmath>      // #include <Math.h>
#include <cstdio>      // #include <cstdio>
#include <cstring>    // #include <cstring>
using namespace std
// C의 표준에 정의된 함수들 조차 이름 공간 std 안에 선언이 되어 있어서 이 문장이 삽입되어야 한다
int main(void)
{
    char str1[]="Result"
    char str2[30];
 
    strcpy(str2, str1);
    printf("%s: %f \n", str1, sin(0.14));
    printf("%s: %f \n", str2, abs(-1.25));
    return 0;
}
cs



* C++의 헤더를 선언해야 하는 이유



Posted by 너래쟁이
: