본문 바로가기

C++

c++ #include <iostream>

728x90

#include <iostream>

iostream 클래스 = istream(입력 input) 클래스 + ostream(출력 ouput) 클래스

 

using namespace std;

//using namespace 를 사용함으로써 cout 이 std namespace 의 객체임을 처음에 정의해줘서

std::cout 에서 std 를 사용하지 않고 cout 만 사용할 수 있음.

 

cout :  출력

cin : 입력

 

<using namespace std 사용 전>

 

int main(void)

{

char irum[30];

std::cout << "hello world!" << std::endl; //endl : endline ( = \n)

int calpoint; // 중간에 자료형 정의해줄 수 있음.

std::cin >> irum;

std::cin.getline(irum, sizeof(irum)); // cin 은 공백없이 연결된 문장, 숫자만 받음. getline은 공백 포함한 문장 받을 수 있음.

std::cout << irum <<"님 ,금회 발생 포인트=" << calpoint << "점 입니다\n";

}

 

 

<using namespace std 사용 후>

int main(void)

{

char irum[30];

cout << "hello world!\n" 

int calpoint;

cin >> irum;

cin.getline(irum, sizeof(irum)); // cin 은 공백없이 연결된 문장, 숫자만 받음. getline은 공백 포함한 문장 받을 수 있음.

cout << irum <<"님 ,금회 발생 포인트=" << calpoint << "점 입니다\n";

}

 

www.youtube.com/watch?v=JoAdRwJi-GI

'C++' 카테고리의 다른 글

[C++] 배열 초기화 { 0, }  (0) 2020.11.09
c++ public vs private  (0) 2020.11.07
c++ 주석처리 단축키 ctrl + k + c/u  (0) 2020.11.07