프로그래밍 언어(154)
-
C언어 매크로 사용법 (2/2. 함수 매크로)
소스 코드에서 반복적으로 사용되는 코드를 간단하게 정의하고 사용할 수 있게 해주는 전처리기(preprocessor) 기능 중 하나로 #define 지시어를 사용하여 정의된다.전처리 단계에서 처리하므로 컴파일 이전에 모두 치환된다. 어느 단계에서 처리가 되는지 아는 것도 중요하다. 매크로는 전처리 단계에서 단순 텍스트 치환이기 때문에 속도는 빠르다, 다만 주의할 점이 많으므로 숙지하고 습관화해야 하는 부분이 존재한다. * 함수 매크로를 사용한 예제들을 확인해보자.간단한 수학 연산예시 (ChatGPT 생성):#include #define SQUARE(x) ((x) * (x))#define MAX(a, b) ((a) > (b) ? (a) : (b))#define MIN(a, b) ((a) [여기서 내용 추가]..
2024.08.03 -
C언어 매크로 사용법 (1/2. 단순 매크로)
소스 코드에서 반복적으로 사용되는 코드를 간단하게 정의하고 사용할 수 있게 해주는 전처리기(preprocessor) 기능 중 하나로 #define 지시어를 사용하여 정의된다.전처리 단계에서 처리하므로 컴파일 이전에 모두 치환된다. 어느 단계에서 처리가 되는지 아는 것도 중요하다. 상수 값 정의코드 내에서 여러번 사용되는 값을 매크로로 정의해서 사용한다. 값에 의미를 부여함으로써 가독성이 올라가고, 값을 변경해야 하는 경우 한번에 수정이 가능하므로 유지보수에 용이하다. 상수를 직접 쓰는 것보다는 이렇게 정의해서 사용하는 것이 좋다. 예시 (ChatGPT 생성):#include #define PI 3.14159#define E 2.71828#define MAX_BUFFER_SIZE 1024int main()..
2024.08.03 -
Namespaces (using - namespace의 특정 맴버)
출처: https://en.cppreference.com/w/cpp/language/namespace Namespaces - cppreference.comNamespaces provide a method for preventing name conflicts in large projects. Entities declared inside a namespace block are placed in a namespace scope, which prevents them from being mistaken for identically-named entities in other scopes. Entities declaren.cppreference.com * using [namespace 맴버] - using ns-na..
2024.08.03 -
Namespaces (using)
출처: https://en.cppreference.com/w/cpp/language/namespace#Namespaces Namespaces - cppreference.comNamespaces provide a method for preventing name conflicts in large projects. Entities declared inside a namespace block are placed in a namespace scope, which prevents them from being mistaken for identically-named entities in other scopes. Entities declaren.cppreference.com * using - using namespace..
2024.08.03 -
Namespaces (스코프)
참고: https://en.cppreference.com/w/cpp/language/namespace Namespaces - cppreference.comNamespaces provide a method for preventing name conflicts in large projects. Entities declared inside a namespace block are placed in a namespace scope, which prevents them from being mistaken for identically-named entities in other scopes. Entities declaren.cppreference.com * 스코프 연산자 기준 위치 - ns-name :: member-..
2024.08.02 -
Tkinter 기본 기능
Tkinter 가져오기import tkinter as tkfrom tkinter import ttk 메인 윈도우 생성root = tk.Tk()root.title("내 Tkinter 앱")root.geometry("400x300") 기본 위젯라벨(Label)label = tk.Label(root, text="안녕하세요, Tkinter!")label.pack() 버튼(Button)def on_click(): print("버튼 클릭됨")button = tk.Button(root, text="클릭하세요", command=on_click)button.pack() 엔트리(Entry)entry = tk.Entry(root)entry.pack() 텍스트(Text)text = tk.Text(root, height=..
2024.07.30