#include <iostream>
/* input output stream
* #'s name = preprocessor directive
* std = namespace
* << = output operator*/
int main()
{
int x=12; // 이렇게 직접적은 initialization(초기화) x(12) 이렇게 쓰기도 함
x = 5; // 이건 assignment
// x 는 L value, 주소를 포함함, 12는 R value
std::cout << &x << std::endl; //& 는 메모리에서 x의 주소를 불러옴.
}
#include <iostream> // cout, cin, endl ... 포함됨
#include <cstdio> // printf
int main()
{
//using namespace std; 이걸 사용하면 std:: 를 안써도 됨.
int x = 1024;
std::cout << "I like cpp" << std::endl; // std::endl 를 없애면 아래와 바로 옆에 붙어서 출력됨.
std::cout << "x is" << x << std::endl; // '\n'을 넣으면 std::endl 와 같이 줄바꿈이 됨.
std::cout << 'abc' << '\t' << 'def' << std::endl; // '\t' 는 탭을 해줌.자동으로 줄맞춤, 깔끔한 줄맞춤 원할 때
std::cout << '\a' << std::endl; //이건 오디오
//printf('hello\n');
}
#include <iostream> // cout, cin, endl ... 포함됨
#include <cstdio> // printf
int main()
{
using namespace std;
int x;
cin >> x; // 위에서 x 로 지정하고 cin 으로 흘러들어가는 것. 정보 입력
cout << "your input is" << x << endl;
}
#include <iostream>
using namespace std;
int addTwoNumbers(int num_a, num_b)
{
int sum = num_a + num_b;
return sum;
}
int main()
{
cout << addTwoNumbers(1,2) << endl;
return 0;
}
댓글 영역