전체 글258 var, foreach, List 자료형 var 2024. 1. 8. if 문 for 문 while 문 Console.WriteLine("-------------------------------------------------"); Console.WriteLine("if 문 for 문 while 문"); int a = 5; int b = 3; int c = 4; if (a + b > 10) { Console.WriteLine("The answer is greater than 10"); } else { Console.WriteLine("The answer is not greater than 10"); } if ((a + b + c > 10) && (a == b)) { Console.WriteLine("The answer is greater than 10"); Console.WriteLine("And the .. 2024. 1. 8. 정수 연산 Console.WriteLine("-------------------------------------------------"); Console.WriteLine("정수, 연산 ..."); int a = 18; int b = 6; int c = a + b; Console.WriteLine(c); c = a / b; Console.WriteLine(c); c = a % 10; Console.WriteLine(c); int max = int.MaxValue; int min = int.MinValue; Console.WriteLine($"The range of integers is {min} to {max}"); int what = max + 3; Console.WriteLine($"An example of o.. 2024. 1. 8. 변수 선언 및 문자열 작업 https://learn.microsoft.com/ko-kr/dotnet/csharp/tour-of-csharp/tutorials/#hello-world C# 소개 - 대화형 자습서 브라우저에서 C#에 대해 알아보고 사용자만의 개발 환경을 시작합니다. learn.microsoft.com 해당 사이트 듀토리얼 Console.WriteLine("-------------------------------------------------"); Console.WriteLine("변수 및 선언, 문자열 작업"); Console.WriteLine("Hello World!"); string aFriend = "Bill"; Console.WriteLine(aFriend); Console.WriteLine("Hello " .. 2024. 1. 8. char , 배열과 포인터 차이 char str[] = "Hello"; - 배열 스택에, 할당된 문자열 데이터는 힙에 const char *str = "Hello"; - 포인터는 스택에, 문자열 상수는 정적 메모리에 char *str = new char[6]; - 포인터는 스택에, 할당된 문자열 데이터는 힙에 ps> str_instance 2024. 1. 4. 스마트 포인터, casting 스마트 포인터 C++은 타 언어와 다르게 가비지 컬렉터가 없기 때문에 동적으로 할당한 메모리에 대해서는 메모리 누수가 발생하기 쉽습니다. 따라서, 동적으로 할당된 메모리를 관리를 위해 C++14부터 스마트 포인터가 생기게 되었습니다. 스마트 포인터에 동적으로 할당된 메모리 경우 특정 기준에 의해 사용이 완료되었다고 판단이 될 때 메모리를 해제해줍니다 스마트 포인터 설명 비고 unique_ptr 한 객체, 하나의 함수에서 만 사용할 때 사용. shared_ptr 특정 포인터의 복사본을 여러 객체나 코드에서 가지고 있을 때(공동 소유권), 이 포인터는 메모리에 대한 참조되는 숫자가 0이 될때 메모리를 해제. 공유될때 마다 레퍼런싱 카운팅을 수행. weak_ptr 지정된 메모리에 대한 소유권을 가지지 않는 포.. 2024. 1. 3. 이전 1 ··· 4 5 6 7 8 9 10 ··· 43 다음