[C++] Hello World

chxxrin·2024년 7월 24일
0

C++

목록 보기
2/22
#include <iostream> // iostream이라는 헤더를 포함(include)

using namespace std; // 네임스페이스 설명 std::cout

int main() // entry point (main함수가 시작지점이다)
{
    // 주석(comment) 다는 방법

    cout << "Hello, World!" << endl;
    // printf("Hello World!!! by printf");

    // 입출력에 대해서는 뒤에 다시 나와요.
    char user_input[100];
    cin >> user_input;
    cout << user_input;

    return 0; // 0이라는 값을 반환
}
  • #include : iostream이라는 헤더를 포함(include)
  • using namespace std; : 네임스페이스 설명 std::cout
  • int main() : entry point (main함수가 시작지점이다, 기본값이다)
  • cout : character out
  • endl : end line (줄바꿈)
  • << : stream insertion operator
  • 함수 끝에는 세미콜론 X
  • 명령문 뒤에는 세미콜론 O
  • return 0 : 0이라는 값을 반환
  • g++ main.cpp -o Ex01.exe : 터미널에서 코드로 직접 실행파일 생성
  • ./Ex01.exe : 터미널에서 코드로 직접 파일 실행

0개의 댓글

관련 채용 정보