Programming/C\C++
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 4 #define _CRT_SECURE_NO_WARNINGS #include #define MAX 10000 cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 int main(void){ // 파일 입출력 // 파일에 어떤 데이터를 저장. // 파일에 저당된 데이터를 불러오기. // fputs, fgets 하나의 쌍 -> 문자열 저장 char line[MAX]; // char line[10000] // 파일에 쓰기 FILE * file = fopen("/Users/janghan/Desktop/Programming/c/test1.txt", "wb"); // r 읽기전용 w 쓰기전용 a 이어쓰기 + // t txt. b binary d..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 #include #include #include cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 int main(void){ // [game 출시] // 이름 : 나도게임 // 발매년도 : 2017년 // 가격 : 50원 // 제작사 : 나도회사 char * name = "나도게임"; int year = 2017; int price = 50; char * company = "나도회사"; // [또다른 game 출시] // 이름 : 너도게임 // 발매년도 : 2017년 // 가격 : 100원 // 제작사 : 너도회사 char * name2 = "너도게임..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 #include #include #include cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 int main(void){ // 다차원 배열 Multidimensional Array int i; // ㅁ int arr[5]; // ㅁㅁㅁㅁㅁ // [0][1][2][3][..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 #include #include #include cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 int main(void){ // 포인터 //철수 : 101호 -> 메모리 공간의 주소 //영희 : 201호 //민수 : 301호 //각 문 앞에 '암호'가 다음과 같이 걸려 있음. int jame = 1; int piter = 2; int mesk = 3; printf("jame네 주소 : %d, 암호 : %d\n", &jame, jame); printf("piter네 주소 : %d, 암호 : %d\n", &piter,piter ); printf("mesk네 주소 : %d, 암호 : %d\n..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include #include #include int main(void){ // 배열 int subway_1 = 30; int subway_2 = 40; int subway_3 = 50; printf("지하철 1호차에 %d명이 타고 있습니다.", subway_1); printf("지하철 2호차에 %d명이 타고 있습니다.", subway_2); printf("지하철 3호차에 %d명이 타고 있습니다.", subway_3); int subway_array[3]; // [0][1][2] subway_array[0] = 30; subway_array[1] = 40; subway_array[..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 #include #include #include cs 위와 같이 라이브러리를 include한 뒤, int main(void) 위 사이에 1 2 // 선언 void p(int num); cs int main(void) 위에 위와 같이 함수를 선언한다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 // function // 계산기 int num = 2; // printf("num은 %d입니다.\n", num); p(num); // 2+ 3 num = num + 3; // printf("num은 %d입니다.\n", num); p(num); // 5-1 num = num -1; // printf("num은 %d입니다.\n", num)..
![](https://tistory1.daumcdn.net/tistory/5081514/skin/images/no-image.jpg)
1 2 3 4 #include #include #include cs 기본적으로, 라이브러리란 자주 사용하는 함수들을 미리 작성하여 저장해둔 파일로써 보통 헤더파일로 저장됨. C언어에서 기본적으로 사용하는 헤더파일은 stdio.h 이며 이 stdio.h 는 Standard Input Ouput(표준 입출력)의 약자. 이 헤더파일은 #include 라는 코드를 통해 추가해 줄 수 있음. rand()함수는 stdlib.h 헤더파일에 포함되어있기 때문에 코드 맨 윗줄에 #include 를 작성. time.h는 타임 값을 받아오는 헤더파일. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 int main(void){ ..