Contents
- 1. 교/startLine
- 2.
- 2.1. 1-, (2012-03-21)
- 2.2. 1- (2012-03-22)
- 2.3. 2- (2012-03-26)
- 2.4. 3- (2012-3-28)
- 2.5. 3-, (2012-3-28)
- 2.6. 4- (2012-4-2)
- 2.7. 4- (2012-4-3)
- 2.8. 5- (2012-4-4)
- 2.9. 5- (2012-4-5)
- 2.10. 4- (2012-4-5)
- 2.11. 6- (2012-4-9) + 7- (2012-4-9)
- 2.12. 8 (2012-5-1) - ,
- 2.13. 9(2012-5-9) - ,
- 2.14. 10(2012-5-22) - ,
- 2.15. 11(2012-5-23) - ,
- 2.16. 12(2012-7-19)
- 2.17. 13(2012-7-20)
- 2.18. 2012-7-30
- 2.19. 2012-8-2
2.3.2. 과 ¶
- 기 - 게 . 각

int main()
{
int num1 , num2 = 1, num3, num4 = 2;
printf(" \n");
scanf("%d", &num1);
num3 = num1 - 1;
while(num2 <= num1){
while(num3 < num1){
printf("*");
num3++;
}
printf("\n");
num3 = num3 - num4;
num2 = num2 + 1;
num4++;
}
return 0;
}
2.3.3. 기 ¶
- - 고 고 고 겠 각.
- - (if, switch.. for...) (switch break, ..) 그고 간간 간 ( 그, python, c) 각 걱 1:1 그 교 . 그고 각 고 기 . 기 C 기 꽤 까 if for . printf, scanf 기 갈기 c 기 고 간 기 .
2.5.3. 기 ¶
- 간게 , . 그 swap 고 기 . 그 고 값 기 기 갔. 개 기 고 , call-by-value 기 꺼 과 까 . 그 그 그 구 게 고 값 기 (call-by-reference) 기. 그고 malloc 과 과 계 . 개 간 극 기 . 구 그 기 게 고 각, 그 기 까 . C C . 그고 구 까 각 . -
- 기 swap 구, 값 . 그고 malloc 기 게 . malloc 그 구 고 . -
- , , malloc , fflush() , getchar() , heap과 stack , (int)a *(*(int a)) , OS 기(DWORD 기 간. 32bit/64bit),
- 깅, , . -
2.9.2. 기 ¶
- 2. 깐 고 그 구 typedef . 그고 구 . 그 typedef int* SOMETHING 기 , 간 . int **twoDim twoDim0 malloc . 근근 . 개 고 (*s).age 꼈. -> * . 구 각고 기. 고. -
- , 구 게 고, "#" . typedef .
2.13.2. 기 ¶
- Callback(winapi 기) + winapi.co.kr
과 5. + .
그 ... 그구 그 .
기 까 . -
- 과 과 CallBack 개과 구 .
기 .
C function 그 걸 깊 게 .
구 겠. -
- 과 . 그 간 게 간 . 고 고 , 그 그 거 경 그 간 까 각 군. 기 . 그 간 굳 과 C char * 고 그 () 공 각 . -
2.13.3. 과 - 기 ¶
- Calender.h - . .
// .
void printCalender(int nameOfDay, int year, int month);
// (nameOfDay)과 1~endDayOfMonth까 .
void printDate(int nameOfDay, int endDayOfMonth);
// 1 ('\t') .
void printFirstTab(int nameOfDay);
// (, , , ) .
void printHeader(int year, int month);
// .
int calculateNameOfNextMonthFirstDay(int nameOfDay, int year, int month);
// .
int calculateNameOfLastDay(int nameOfDay, int year, int month);
// .
bool isLeapYear(int year);
// 각 .
// switch-case , 2 .
int endDayOfMonth(int year, int month);
// 각 값 . (ex. 0-"Sun", 1-"Mon" ...)
// switch-case .
char *printMonthName(int i);
- main.cpp
#include <stdio.h>
#include "Calender.h"
int main(int argc, char *args[]) {
// year (nameOfDay) .
int year = 0, nameOfDay = 0;
printf("Enter the year : ");
scanf("%d", &year);
printf("Enter the name of day(0:sun ~ 6:sat) : ");
scanf("%d", &nameOfDay);
// 1~12 .
for ( int month = 1; month <= 12; month++ ) {
printCalender(nameOfDay, year, month);
nameOfDay = calculateNameOfNextMonthFirstDay(nameOfDay, year, month);
}
return 0;
}
- sample output - 1 12까. 게 고 ('\t') .
January, 2012
-------------------------------------------------
Sun Mon Tue Wed Thu Fri Sat
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
2.13.4. 기 ¶
- strcat(str1, str2) str1 .
People p; strcat . p 기(People p = {0};) 고
p.name 기 값 . 그 strcat p.name (p.name99 ) "길" .
기 p 기 고 거 memset(p.name, 0, sizeof(char)*100); .
#include <stdio.h>
#include <string.h>
typedef struct People{
char gender;
int age;
char name[100];
char real_name[100];
} People;
int main()
{
char str1[100] = "abc";
char str2[100] = "aaa";
People p;
strcat(p.name, "길");
strcat(str1, str2);
printf("%s", str1);
getchar();
return 0;
}
2.14.1. ¶
- 금 기 구 고 기
구 .
- 그 .
그고 addAccount() deleteAccount() .
#include <stdio.h>
typedef struct Account {
char *name;
int money;
} Account;
typedef struct AccountArray {
struct Account **accounts;
int currentAccountNumber;
int maxLength; // 길 구 .
} AccountArray;
Account *createAccount(char *name); // Account 깔게 기 .
AccountArray *createAccountArray(int maxLength);
void addAccount(AccountArray *accountArray, char *name);
bool isFull(AccountArray *accountArray); // 게 까??????
AccountArray *extendArray(AccountArray *before); // .
void deleteAccount(AccountArray *accountArray, char *name); // 간 ? 간 구 ?
void deposit(AccountArray *accountArray, char *name, int money); // accountArray 교 겠.
void withdraw(AccountArray *accountArray, char *name, int money);
void addAccountMenu();
void deleteAccountMenu();
void depositMenu();
void withdrawMenu();
main.cpp
#include <stdio.h>
#include "Account.h"
int main(int argc, char *argv[]) {
int select = 0;
// .
while ( true ) {
printf("select menu : ");
printf("1: 계 \n");
printf("2: 계 \n");
printf("3: 금\n");
printf("4: 금\n");
scanf("%d", &select);
switch ( select ) {
case 1:
addAccountMenu();
break;
case 2:
deleteAccountMenu();
break;
case 3:
depositMenu();
break;
case 4:
withdrawMenu();
break;
default:
break;
}
}
return 0;
}
2.15.1. ¶
////////////////////////////////////// 기 , 기 + char a; // a ? 1. a 그기. a = ?? // 값 기 기. int b; // b ? 1. b 그기. b = ?? // 값 기 기. char c[10]; // c ?, 1. 과 0 기 기., 2. 기 기., 3. c[0] ? char *d; // d ? char 10개 과 기 기. // c d 각각 그기. . ??? // [] c 근 기. ??? // d 근 기. ??? // c 근 기. // array[0] == *(array + 0) 근 게 근 . //////////////////////////////////////// , + Person p; // p ? 1. p 그기. ??? // p 근기. Person pArr[10]; // pArr ? 1. pArr 그기. ??? // pArr 0 근기 Person *p2; // p2 ? 1. p2 그기. ??? // p2 기 기. ??? // p2 근기. Person *ppa[10] // ppa ? 1. ppa 그기., 2. ppa[0] ? 3. ppa[0] 기 기. 4. ppa[0] 근 기. Person **ppb // ppb ? 1. ppb 그기., 2. ppb[0] ? 3. ppb[0] 기 기., 4. ppb[0] 근 기.
2.16.1. ¶
- AccountArray 기.
- createAccount(char *name) Account * .
Account makeAccount(char *name) {
Account account;
account.money = 0;
account.name = (char *)malloc(sizeof(char) * (strlen(name)+1));
strcpy(account.name, name);
return account;
}
void addMoney(Account account, int money) {
account.money += money;
}
그 Account 게 .Account 그 겨게 call-by-value Account 고 money 기
Account .
- extendArray .
2.17.1. ¶
- 간.
- LinkedList 개.
- ArrayList(Array) LinkedList 교.
- LinkedList 구 과 구 경 (경 ).
- LinkedList.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int Data;
typedef struct Node {
Data data;
Node *nextNode;
} Node;
typedef struct LinkedList {
int length;
Node *headNode;
} LinkedList;
LinkedList *createList();
Node *createNode(Data data);
void deleteList(LinkedList *linkedList); // LinkedList까 .
void addData(LinkedList *linkedList, Data data); // LinkedList Data Node .
void removeData(LinkedList *linkedList, Data data); // Data Node .
Node *getData(LinkedList *linkedList, int position); // index Node .
void clearList(LinkedList *linkedList); // LinkedList Node .
void printList(LinkedLIst *linkedList);
2.17.2. ¶
#include "LL.h"
LinkedList *createList(){
LinkedList *res;
res = (LinkedList *)malloc( sizeof(LinkedList) );
(*res).headNode = NULL;
(*res).length = 0;
return res;
}
Node *createNode(Data data){
Node *res;
res = (Node *)malloc( sizeof(Node) );
(*res).data = 0;
(*res).nextNode = NULL;
return res;
}
void deleteList(LinkedList *linkedList){
clearList(linkedList);
free(linkedList);
}
void addData(LinkedList *linkedList, Data data){
Node *node = createNode( data );
Node *temp = linkedList->headNode;
for(;temp->nextNode != NULL;){
temp = temp->nextNode;
}
temp->nextNode = node;
}
void removeData(LinkedList *linkedList, Data data){
int onoff = 0; //for duty of switch
Node *remove = linkedList->headNode;
if( remove->data == data ){
free( remove ); //If the object is headNode
onoff = 1;
}
if( onoff == 0 && remove->nextNode->data == data ){
free( remove->nextNode ); //If the object is the nextNode of headNode
onoff = 1;
}
for(; onoff == 0 && remove->nextNode->data != data;){ //...
remove = remove->nextNode;
}
remove->nextNode = remove->nextNode->nextNode; // remove remove-n remove-n-n
free(remove->nextNode); // remove ~ remove-n-n , free remove-n
}
Node *getData(LinkedList *linkedList, int position){
Node *get = linkedList->headNode;
for( int i = 0 ; i < position ; i++ ){
get = get->nextNode;
}
return get;
}
void clearList(LinkedList *linkedList) {
Node *now = (*linkedList).headNode;
Node *next;
for( ; (*now).nextNode != NULL ; ){ //now
next = (*now).nextNode; //next now
free( now ); //now free
now = next; //next now
}
free( now ); //now free
}
int lengthOf(LinkedList *linkedList){
int length = 0;
Node *temp = linkedList->headNode;
for( ; temp->nextNode != NULL ; length++ ){
temp = temp->nextNode;
}
return length;
}
void printList(LinkedList *linkedList){
Node *temp = linkedList->headNode;
for( ; temp->nextNode != NULL ; ){
printf("%d\t", temp->data);
temp = temp->nextNode;
}
printf("\n");
}
2.18.1. ¶
int main() {
Stack *stack = createStack();
assert(stack->elementNumber == 0);
assert(stack->head == NULL);
push(stack, 10);
assert(stack->elementNumber == 1);
assert(peek(stack)->data == 10);
push(stack, 20);
assert(stack->elementNumber == 2);
assert(peek(stack)->data == 20);
assert(pop(stack)->data == 20);
assert(stack->elementNumber == 1);
Node *result = pop(stack);
assert(result->data == 10);
assert(isEmpty(stack));
return 0;
}










