분류 전체보기 썸네일형 리스트형 C++ 13일차 동적 할당 C++ 동적할당 C++에서는 동적으로 변수나 배열을 할당 할수 있는데 다음 예제를 보면서 해봅시다. 1234567891011121314151617#include #include using namespace std; int main() { int *a = new int(5); cout 더보기 C++ 12일차 C++ 12일차 연산자 오버로딩 1234567891011121314151617181920212223242526272829303132333435363738394041424344#include #include using namespace std; class Vector2 {public: Vector2(); Vector2(float x, float y); float GetX() const; float GetY() const; Vector2 operator+(const Vector2 rhs) const;private: float x; float y;}; Vector2 Sum(Vector2 a, Vector2 b) { return Vector2(a.GetX() + b.GetX(), b.GetX() + b.GetY.. 더보기 fake ebp에 잘 알수 있는 사이트 http://blog.naver.com/PostView.nhn?blogId=noish&logNo=100050649974&parentCategoryNo=94&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView 더보기 C언어 stdio.h 파일 1편 C언어 stdio.h 파일입출력 fopen fopen은 파일을 열때 사용하는 것으로 읽기모드나 쓰기모드등으로 열수 있다 ex. fopen(자신이 열고자 하는 파일 이름, 읽기모드나 쓰기모드) 1234567#include #include int main(void){ FILE *f = fopen("test.txt","w"); return 0;}Colored by Color Scriptercstest.txt라는 파일을 읽기 모드로 열기 1234567#include #include int main(void){ FILE *f = fopen("test.txt","r"); return 0;}Colored by Color Scriptercstest.txt라는 파일을 읽기 모드로 열기 fprintf는 파일의 내용을 채우.. 더보기 C언어 string.h 3번째 C언어 string.h 3번째 memset memset은 배열을 자기가 원하는 값으로 초기화시키는 것입니다. ex.memset(arr,0,12); -> arr이라는 배열에 12번째까지 0으로 초기화 시키는 것입니다. 123456789#include #include int main(void){ char arr[12]; memset(arr,'a',12); printf("%s",arr); return 0;}cs위의 예제는 arr를 a라는 문자형으로 초기화 시켜 출력하는 예제입니다. 따라서 a가 12번 나옵니다 memcpy ex.memcpy(arr,str,10) - >arr의 10번째까지 str의 내용을 바이트 형태로 넣겠다는 소리입니다. 12345678910#include #include int main(vo.. 더보기 C언어 string.h2 C언어 string.h 2탄 strncpy strcpy에서 글자수를 제안하여 복사할수 있는 함수이다. ex.strncpy(str1,str2,2); ->이런식으로 하면 str1에 str2에 있는 내용이 들어가지만 str2옆에 2가 있어서 str2의 앞의 두글자만 들어간다. 12345678910#include #include int main(void){ char k[100] = "HELL"; char s[100]; strncpy(s,k,2); printf("%s",s); return 0;}cs위의 예제는 strncpy를 잘 나타내는 함수이다. 이걸 돌리게 되면 k에 있는 HELL이라는 문자형중 앞의 2글자만 들어가서 출력하면 HE만 나오게 된다. strncat strncat은 글자수를 제한하여 뒤에 붙여 넣.. 더보기 C언어 string.h C언어 String.h strlen은 문자열의 길이를 받는 함수이다. 12345678910#include #include int main(void){ char k[100] = "HELL"; int s = 0; s = strlen(k); printf("%d",s); return 0;}cs위의 함수는 strlen을 잘 알려주는 예제이다. char k[100]에는 HELL라는 글자가 들어 있는데 이 글자수는 4개이다. 따라서 s라는 변수에 4가 들어간다. strcpy는 문자열을 복사해서 붙여넣는 함수이다. 12345678910#include #include int main(void){ char k[100] = "HELL"; char s[100]; strcpy(s,k); printf("%s",s); return.. 더보기 C++ 11일차 C++ 11일차 멤버 메서드 사용하기 12345678910111213141516171819202122232425262728293031323334#include using namespace std; class vector2 {public: vector2() :x(0), y(0) {} vector2(float x, float y) : x(x), y(y) {} float GetX() const; float GetY() const;private: float x; float y;}; vector2 Sum(vector2 a, vector2 b) { return vector2(a.GetX() + b.GetX(), a.GetY() + b.GetY());} int main() { vector2 a(2, 3); vecto.. 더보기 C++ 10일차 C++ 10일차 상수형 매개변수와 상수형 메서드 혹시 const라는 것을 아시나요? C++을 하시는 분들이라면 C언어는 마스터 하고 공부하시는 거라 믿고 설명하겠습니다. const는 변수를 상수화 하여 그 값을 변경을 하지 못하게 하는 것입니다. 아래의 예제를 보도록 하죠. 1234567891011121314151617181920#include using namespace std; class count1 {public : count1() : money(0) {} int money1() const { money++; return money; }private : int money;}; int main(void) { count1 a; cout 더보기 C++ 9일차 C++ 9일차 정적멤버 https://www.youtube.com/watch?v=SJx5czHKSy8&index=63&list=PLlJhQXcLQBJqywc5dweQ75GBRubzPxhAk https://www.youtube.com/watch?v=ZoK_VFoycas&list=PLlJhQXcLQBJqywc5dweQ75GBRubzPxhAk&index=64 요건 두들낙서 님의 정적 멤버에 관한 동영상입니다. 정적멤버에 대해 어떻게 설명할지를 몰라 대신 동영상을 올립니다. 더보기 이전 1 2 3 4 5 6 다음