PowerPoint 프레젠테이션

Size: px
Start display at page:

Download "PowerPoint 프레젠테이션"

Transcription

1 전산 SMP 8 주차 김범수 bskim45@gmail.com Special thanks to 박기석 (kisuk0521@gmail.com)

2 지난내용복습 Dynamic Memory Allocation

3 왜쓰나요? 배열의크기를입력받아그크기만큼의배열을만들고싶을때 int main(void) { int size; scanf( %d, &size); } int array[size]; Compile Error! 선언은항상맨위에와야한다. 선언후에배열이할당되어야하는데 이럴때는어떻게? 프로그램실행중에메모리를할당해데이터를저장할공간을생성하는방법

4 A Conceptual View of Memory We can refer to memory allocated in the heap only through a pointer.

5 Accessing Dynamic Memory

6 malloc 지정하는크기 (byte) 만큼메모리 ( 힙 ) 를할당 기본적으로 void * 로리턴 원하는타입으로 casting 해줘야한다 할당에실패한경우 NULL 리턴 void *malloc (size_t size); int* p = (int *)malloc(sizeof(int) * 4); int 형의크기가 4byte 이기때문에 16byte 의공간이동적으로할당 char *str = (char *)malloc(sizeof(char) * 10);

7 calloc void *calloc (size_t count, size_t size); count * size 만큼의메모리를할당하고해당힙영역을 0 으로초기화하여반환 int *p = (int *)calloc(4, sizeof(int)); char *str = (char *)calloc(10, sizeof(char)); malloc(sizeof(int)*4) calloc(4, sizeof(int))

8 realloc 할당받은메모리공간을새로운크기로재할당 void *realloc(void *ptr, size_t newsize); int *p = (int *)calloc(4, sizeof(int)); p = (int *)realloc(p, sizof(int) * 6); char *str = (char *)calloc(10, sizeof(char)); str = (char *)realloc(str, 20*sizeof(char));

9 free 동적할당한메모리반환 사용하지않을때 & 프로그램의마지막에반드시반환해야한다! void free (void * ptr); free(ptr); free(str);

10 동적할당으로 2 차원배열만들기 포인터배열 int **table; table = (int **)calloc (3, sizeof(int *)); table[0] = (int *)calloc(4, sizeof(int));

11 포인터의부적절한사용으로인한주요부작용들 Unreachable Memory ( 이공간을가리키는포인터가존재하지않는다 ) Dangling Pointer ( 어딘가가리키고있기는하지만, 그위치에뭐가있는지알수없다.) Buffer Overflow ( 할당되어있는양이상으로메모리를다루게되는경우 ) Segmentation Fault ( 잘못된주소접근 ) 11

12 허공에뜬메모리공간 (unreachable memory) { char *str; (1) str = (char *) malloc(200 * sizeof(char)); (2) (no free()!!) str = (char *) malloc(123 * sizeof(char)); (3) } (1) (2) (3) str str str??? 200 byte space 200 byte space Another 123 byte space

13 길잃은포인터 (dangling pointer) char *cp = NULL; (1) /*... */ { char c; cp = &c; (2) } /* c로할당되었던메모리공간이이시점에서할당해제된다. */ /* cp는이제길잃은포인터 (dangling pointer) 가되어버렸다. */ (3) (1) (2) (3) cp NULL cp cp??? c c c 변수가사라진상황. 이후에이공간이어떻게사용될지아무도모른다.

14 Buffer overflow 버퍼 (buffer) 컴퓨터내에서사용되는임시저장소 ( 메모리공간 ) 컴퓨터에서일어나는대부분의작업은효율을위해버퍼를많이사용한다. Buffer overflow Overflow = 넘친다 저장한내용이할당되어있는버퍼의영역바깥으로넘치는것 만일넘친영역이다른용도로사용되고있었다면, 그원래의값을파괴해버린다. 넘친영역의값이파괴됨을이용하여대상컴퓨터를혼란시켜침입하는기법이많이사용된다.

15 잘못된연산오류 (Segmentation fault) 지정한영역이외에엉뚱한위치 ( 주로 null 혹은쓰레기값 ) 를가리키는포인터가가리키는위치에다가어떤값을써넣으려고시도하는경우에발생한다. 현재각포인터가가리키는위치가유효한지꼼꼼히살펴봐야한다. e.g. int *p; // 초기화없이선언 *p = 123; // 초기화되지않은포인터 dereferencing 여긴어디나는누구? printf("%d\n", *p); //???

16 Tidy Up 동적으로할당된메모리는반드시시스템에반환해야함! 그래야다른프로그램이메모리공간을활용할수있다. ( 메모리 leak) 실행전에미리할당 vs 실행중에동적으로할당하고반환 공간이필요한만큼만쓰기때문에효율적! 메모리공간의크기는정해져있다. 얼마나큰공간이필요한지알수없을때 적당히크게? 공간이부족하거나, 공간이낭비되거나

17 오늘할것 Enumeration, Structure, Union String (Advanced) - 하는데까지

18 Structure

19 The Type Definition (typedef) A type definition, typedef, gives a name to a data type by creating a new type that can then be used anywhere a type is permitted. 프로그래머는길게쓰는것을싫어한다 typedef int INGETER;

20 Derived Type 프로그래머가임의로만든타입

21 Enumerate Type 항목혹은선택지, 일종의상수항목을만들때사용 각항목들에대해 identifier 로써하나의정수 (enumeration constant) 가할당됨 상황 ) 메뉴를만들고숫자하나입력받아서 switch 문으로각기다른함수를실행해야한다. 그냥숫자 0, 1, 2, 3 으로나누면나중에헷갈리고불편함

22 Declaring an Enumerated Type enum typename { identifier list }; enum COLOR { RED, BLUE, GREEN, WHITE }; enum COLOR skycolor;

23 Initializing Enumerated Constants enum MONTHS {JAN, FEB, MAR, APR}; identifier 자동배정 enum MONTHS {JAN = 1, FEB, MAR, APR}; enum COLORS {RED, ROSE=0, CRIMSON=0, BLUE, AQUA=1};

24 Operations on Enumerated Types enum COLORS color1, color2; color1 = BLUE; color2 = color1; if (color1 == color2) if (color1 == BLUE) switch (color1) { case BLUE:

25 Enumeration Type Conversion int 형과자동으로호환됨 int x; enum COLORS y; x = BLUE; y = 2; enum COLORS y; y = (enum COLORS) 2;

26 Anonymous Enumeration: Constants enum {space =, comma =,, colon = : }; enum {OFF, ON};

27 Structure Type 관련되는 element 들의집합. 어떤타입의변수라도올수있다. 단, 함수는구조체의 element 로안된다. 오직변수만가능

28 Structure Declaration

29 Initializing Structures

30 Accessing Structure Elements (*pointername).fieldname pointername - >fieldname.

31 Nested Structure

32 Arrays in Structures

33 Array of Structures

34 Passing Structures Through Pointers

35 Structure Application Structure 배열 Structure 포인터배열 struct AA ary[10]; struct AA *ary[10]; 한 Structure 안의포인터 element 가다른 Structure 를가리킨다 Linked List 의핵심개념!!

36 Example 이름, 나이, 성별 (enum), 학년 (enum) 을포함하는구조체 크기 5 짜리구조체배열만들고여기있는사람에대한정보하나씩넣기 for 문으로각구조체에들어간거전부출력 학년 FRESHMAN SOPHOMORE JUNIOR SENIOR 성별 MALE FEMALE

37 Union Types 구조체와비슷하다. 선언및사용도구조체처럼 단, Element 들이메모리를공유 전체구조체크기 = 구조체내부의가장큰변수의크기

38 Example typedef union { short num; char chary[2]; } SHORTCHAR; SHORTCHAR data; data.num = 16706; // = 65 66

39 Union Application 메모리공간을절약할수있고, 두가지구조체역할을할수있으므로간단 단, 헷갈리지않는다면

40 String

41 문자열 (string) 도결국은배열이다 char 형의배열 끝에널문자 \0

42 문자열의선언 char str[15] = Good Day ; 할당한용량을모두사용할필요는없습니다. char month[] = January ; 배열크기가문자열의길이에맞춰자동으로설정 char *pstr = Good Day ; char str[9] = { G, o, o, d,, D, a, y, \0 };

43 문자열의포인터 배열의이름은첫번째 element 의주소와같다. 그래서 scanf 로 %s 받을때 & 안붙인다! str[0] H e l l o W o r l d! \0 str &str[0]

44 문자열포인터사용주의점 반드시동적할당해주거나어떤문자열의주소를넣어주어야한다.

45 String Copy? char str1[6] = Hello ; char str2[6]; str2 = str1; //?

46 String Input/Output Functions #include <stdio.h> formatted input/output functions scanf/fscanf printf/fprintf special set of string-only functions get string (gets/fgets) put string ( puts/fputs ).

47 FLUSH 스트림버퍼를비우는역할을한다. Scanf 등입력받는함수사용시 The string conversion code(s) skips whitespace. ex) int a; char b; scanf( %d, &a); scanf( %c,&b); printf( %d %c\n, a, b); fflush(); #define FLUSH while(getchar!= \n )

48 Formatted String Input char str[10]; scanf( %9s, str); str - 배열포인터 & 가붙지않음 입력문자개수를반드시정의해주자

49 String-only Input: gets/fgets

50 gets( ) char * gets(char *str); Reads characters from stdin, until either a newline or EOF Params str: pointer to an array of chars 길이제한없음 ( 보안상취약 ) Return value Success: returns str (incl. \0 at the end) EOF: feof() set, 여태까지읽은 str return 아무것도못읽으면 : NULL

51 fgets( ) char * fgets (char *str, int num, FILE *stream); Reads characters from stream, until (num-1) characters have been read OR either a newline or the EOF Params str : pointer to an array of chars num : Maximum number of characters (incl. null) 문자는최대 (num-1) stream : Pointer to a FILE that identifies an input stream Return value Success: returns str (incl. \0 at the end) EOF: sets EOF(feof), 여태까지읽은 str 리턴 아무것도못읽으면 : NULL

52 Difference btw. Input functions gets/fgets gets does not include newline ( \n ), fgets does. gets does not allow to specify a maximum size for str (which can lead to buffer overflows). Scanf/gets scanf 는단어단위로 (space), gets 는줄단위로 (newline)

53 String-only Output: puts/fputs

54 puts( ) int puts ( const char * str ); Writes str to stdout and appends a newline character ('\n') until null( 0\ ). Terminating null-character is not copied to the stream. Params str: pointer to an array of chars Return value Success: returns a non-negative value Error: returns EOF(-1) and sets the error indicator (ferror)

55 fputs( ) int fputs ( const char * str, FILE * stream ); Writes str to the stream until null ('\0'). Terminating null-character is not copied to the stream. Params str: pointer to an array of chars stream: Pointer to a FILE object that identifies an output stream. Return value Success: returns a non-negative value Error: returns EOF(-1) and sets the error indicator (ferror)

56 Difference btw. Output functions puts appends a newline( \n) at the end automatically fputs does not write additional characters

57 입력한문자열에서입력한문자개수세기 #include <stdio.h> main() { char str[30],ch; int i=0, cnt=0; // scanf("%s",str); // scanf쓰면 apple의마지막엔터가 ch에들어가므로쓰면안됨 gets(str); // scanf("%c", &ch); // 한문자입력은 scanf, getchar 모두가능 ch=getchar(); while(str[i]!='\0'){ if(str[i++]==ch) cnt++; } printf("%s에서 \'%c\' 문자가 %d개입니다.\n", str, ch, cnt); } 57

58 String Manipulation Functions #include <string.h> String Length and String Copy String Compare and String Concatenate Character in String Search for a Substring and Search for Character in Set String Span and String Token String to Number

59 String Length unsigned int strlen ( const char * str ); Returns the length of the C string str, until null( \0 ). Params str: pointer to an array of chars Return value The length of string.

60 Example char mystr[100]="test string"; sizeof(mystr) evaluates to 100 strlen(mystr) returns 11.

61 String Copy char * strcpy ( char * destination, const char * source ); char * strncpy ( char * destination, const char * source, unsigned int num );

62 String Compare int strcmp ( const char * str1, const char * str2 ); int strncmp( const char * str1, const char * str2, int size); Results for String Compare 문자비교 - 아스키코드순으로

63 String Concatenation char * strcat ( char * destination, const char * source ); char * strncat ( char * destination, const char * source, unsigned int num );

64 Character in String char * strchr ( const char * str, int character ); Return Value A pointer to the first occurrence of character in str. If the character is not found, the function returns a null pointer.

65 String/Data Conversion #include <stdio.h> String to Data Conversion Data to String Conversion

66 sscanf( ) Read formatted data from string sscanf is a one-to-many function. It splits one string into many variables.

67 sscanf ( ) int sscanf (const char *str, const char *format, ); Reads data from str and stores them according to parameter format into the locations given by the additional arguments scanf stdin/ sscanf str Params str: Pointer to source char arrays format: Pointer to a format string... (additional arguments): Sequence of additional arguments depending on the format string with the appro priate type. Additional arguments are ignored. Return value Success: returns the number of items in the argument list successfully filled. Failure: EOF(-1) is returned.

68 Example int main () { char sentence []="Rudolph is 12 years old"; char str [20]; int i; sscanf (sentence,"%s %*s %d",str,&i); printf ("%s -> %d\n",str,i); } return 0; Output: Rudolph -> 12

69 sprintf( ) Write formatted data to string sprintf is a many-to-one function. It joins many pieces of data into one string.

70 sprintf ( ) int sprintf ( char * str, const char * format,... ); Composes a string and stores it as a C string in the buffer pointed by str according to the format. printf stdout, sprint str A terminating null character( \0 ) is automatically appended after the content. Parameters str: Pointer to a buffer where the resulting C-string is stored. The size of the buffer should be large enough to contain the entire resulting string (snprintf for a safer version). format: C string that contains a format string... (additional arguments): a sequence of additional arguments, depending on the format string. Additional argumen ts are ignored. Return value Success: the total number of characters written is returned. (w/o null-character) Failure: a negative number is returned.

71 Example #include <stdio.h> int main (void) { char buffer [50]; int n, a=5, b=3; n = sprintf (buffer, "%d plus %d is %d", a, b, a+b); printf ("[%s] is a string %d chars long\n",buffer,n); return 0; } Output: [5 plus 3 is 8] is a string 13 chars long

72 More at 수업시간에한것들은한번씩찾아보고사용법익히기

73 Assn #4 - Prob 1: String 처리함수구현하기 int mystrlen(char *str); char *mystrcpy(char *tostr, char *fromstr); char *mystrcmp(char *str1, char *str2); char *mystrcat(char *str1, char *str2); char *mystrchr(char *str, char ch); int myatoi(char *str); 이건저번어싸인에서했고 위에서기본적인원리는다했죠? ^^

74 Assn #4 Prob 2 최소 5 개이상의함수작성 - 파일로부터리스트를생성하는부분 (1 개의함수 ) 과각메뉴 (4 개의함수 ) 특정학생의정보및과목정보는구조체의변수에저장, 프로그램내부에서동적할당된구조체포인터의배열을이용하여관리 = 필요할때마다동적할당해서쓰세요 C:\> assn4.exe students.txt Argument Passing - int main(int argc, char* args[]) 예외처리 - 파일읽기에서읽을파일이존재하지않을경우 : fopen 의 r 모드리턴값 NULL 파일읽기 fgets 가 NULL 을리턴할때까지 (EOF)

75 Assn #4 Prob 2 typedef struct { int id; char name[11]; char dept[7]; int level; int sub_num; TAKING_SUBJECTS subjects[max_taking_subject_num]; } STUDENT; 1. 학생별성적 stu_list 한번돌면서 STUDENT 안에 subjects 배열한번돌고 2. 과목별성적 학생명단을출력하는게좀짜증나는데, 역시 stu_list 돌면서 subjects 배열에해당과목이있으면출력해주면되겠죠 ~ STUDENT* stu_list[max_student_num]; SUBJECT* sub_list[max_subject_num]; 3. 저장하기 For 문으로배열돌면서주어진틀에맞춰서 fputs 만잘써주면되겠네요 ~

76 다음시간 어싸인너무쉽다 Various Data Structures implemented with Lists

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 전산 SMP 7 주차 2015. 11. 17 김범수 bskim45@gmail.com Special thanks to 박기석 (kisuk0521@gmail.com) 지난내용복습 Pointer and its applications Pointer 란? 데이터접근에사용되는주소를저장하는타입 포인터도타입이다 int a = 4; char c = a ; int *p = &a;

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2 제 17 장동적메모리와연결리스트 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

61 62 63 64 234 235 p r i n t f ( % 5 d :, i+1); g e t s ( s t u d e n t _ n a m e [ i ] ) ; if (student_name[i][0] == \ 0 ) i = MAX; p r i n t f (\ n :\ n ); 6 1 for (i = 0; student_name[i][0]!= \ 0&&

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

歯7장.PDF

歯7장.PDF 7 Hello!! C 2 . 3 ([] ) < > [ ]; int array[10]; < > [ ][ ]; int array [3] [5]; 4 < > [ ]={ x1,,x10} ( ); (,). ({}). : int array[10]={1,2,3,4,5,6,7,8,9,10}; (" "). : char array[7]="turbo-c"; 5 int array[2][3]={{1,2},{3,4},{5,6}};

More information

chap7.PDF

chap7.PDF 7 Hello!! C 2 . 3 ([] ) < > [ ]; int array[10]; < > [ ][ ]; int array [3] [5]; 4 < > [ ]={ x1,,x10} ( ); (,). ({}). : int array[10]={1,2,3,4,5,6,7,8,9,10}; (" "). : char array[7]="turbo-c"; 5 int array[2][3]={{1,2},{3,4},{5,6}};

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

<4D F736F F F696E74202D20C1A63137C0E520B5BFC0FBB8DEB8F0B8AEBFCD20BFACB0E1B8AEBDBAC6AE>

<4D F736F F F696E74202D20C1A63137C0E520B5BFC0FBB8DEB8F0B8AEBFCD20BFACB0E1B8AEBDBAC6AE> 쉽게풀어쓴 C 언어 Express 제 17 장동적메모리와연결리스트 이번장에서학습할내용 동적메모리할당의이해 동적메모리할당관련함수 연결리스트 동적메모리할당에대한개념을이해하고응용으로연결리스트를학습합니다. 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것

More information

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7> 제14장 동적 메모리 할당 Dynamic Allocation void * malloc(sizeof(char)*256) void * calloc(sizeof(char), 256) void * realloc(void *, size_t); Self-Referece NODE struct selfref { int n; struct selfref *next; }; Linked

More information

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning C Programming Practice (II) Contents 배열 문자와문자열 구조체 포인터와메모리관리 구조체 2/17 배열 (Array) (1/2) 배열 동일한자료형을가지고있으며같은이름으로참조되는변수들의집합 배열의크기는반드시상수이어야한다. type var_name[size]; 예 ) int myarray[5] 배열의원소는원소의번호를 0 부터시작하는색인을사용

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 10 포인터 01 포인터의기본 02 인자전달방법 03 포인터와배열 04 포인터와문자열 변수의주소를저장하는포인터에대해알아본다. 함수의인자를값과주소로전달하는방법을알아본다. 포인터와배열의관계를알아본다. 포인터와문자열의관계를알아본다. 1.1 포인터선언 포인터선언방법 자료형 * 변수명 ; int * ptr; * 연산자가하나이면 1 차원포인터 1 차원포인터는일반변수의주소를값으로가짐

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

Microsoft PowerPoint - chap11-포인터의활용.pptx

Microsoft PowerPoint - chap11-포인터의활용.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 포인터를 사용하는 다양한 방법에

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 5 강. 배열, 포인터, 참조목차 배열 포인터 C++ 메모리구조 주소연산자 포인터 포인터연산 배열과포인터 메모리동적할당 문자열 참조 1 /20 5 강. 배열, 포인터, 참조배열 배열 같은타입의변수여러개를하나의변수명으로처리 int Ary[10]; 총 10 개의변수 : Ary[0]~Ary[9]

More information

Microsoft PowerPoint - Chapter_04.pptx

Microsoft PowerPoint - Chapter_04.pptx 프로그래밍 1 1 Chapter 4. Constant and Basic Data Types April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 기본자료형문자표현방식과문자자료형상수자료형변환 기본자료형 (1/8) 3 변수 (Variables)

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

Microsoft PowerPoint - 제9강 문자열

Microsoft PowerPoint - 제9강 문자열 제11장 문자열 문자열정의 문자열과포인터, 문자열과배열 2 차원문자열배열, 2 차원문자열포인터 문자열함수, 헤더파일 string.h ctype.h strlen(), strcat(), strcpy(), strstr(), strchr(), strcmp(), strtok() getc(), putc(), fgetc(), fputc(), gets(), puts(),

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

Microsoft PowerPoint - C프로그래밍-chap15.ppt [호환 모드]

Microsoft PowerPoint - C프로그래밍-chap15.ppt [호환 모드] Chapter 15 문자열 2009 한국항공대학교항공우주기계공학부 (http://mercury.kau.ac.kr/sjkwon) 1 문자의집합체 문자열의정의 일련의문자 C 언어에서문자열앞뒤에인용부호 를이용 문자와문자열과의차이 문자열의저장 (1) 배열을이용하는방법 문자열상수 c c language 를저장하는문자열배열 항상문자열마지막에는 NULL문자를넣어야함 (2)

More information

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf(hihi\n); } warning: conflicting types for functiona 이름 : 학번 : A. True or False: 각각항목마다 True 인지 False 인지적으세요. 1. (Python:) randint 함수를사용하려면, random 모듈을 import 해야한다. 2. (Python:) '' (single quote) 는한글자를표현할때, (double quote) 는문자열을표현할때사용한다. B. 다음에러를수정하는방법을적으세요.

More information

untitled

untitled 1 hamks@dongguk.ac.kr (goal) (abstraction), (modularity), (interface) (efficient) (robust) C Unix C Unix (operating system) (network) (compiler) (machine architecture) 1 2 3 4 5 6 7 8 9 10 ANSI C Systems

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

Microsoft PowerPoint - Chapter_09.pptx

Microsoft PowerPoint - Chapter_09.pptx 프로그래밍 1 1 Chapter 9. Structures May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 구조체의개념 (1/4) 2 (0,0) 구조체 : 다양한종류의데이터로구성된사용자정의데이터타입 복잡한자료를다루는것을편하게해줌 예 #1: 정수로이루어진 x,

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4 Introduction to software design 2012-1 Final 2012.06.13 16:00-18:00 Student ID: Name: - 1 - 0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x

More information

구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined data types) : 다양한자료형을묶어서목적에따라새로운자료형을

구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined data types) : 다양한자료형을묶어서목적에따라새로운자료형을 (structures) 구조체정의 구조체선언및초기화 구조체배열 구조체포인터 구조체배열과포인터 구조체와함수 중첩된구조체 구조체동적할당 공용체 (union) 1 구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined

More information

Microsoft PowerPoint - chap06-4 [호환 모드]

Microsoft PowerPoint - chap06-4 [호환 모드] 2011-1 학기프로그래밍입문 (1) chapter 06-4 참고자료 문자열의처리 박종혁 Tel: 970-6702 Email: jhpark1@seoultech.ac.kr h k 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- ehanbit.net 문자열의연산 문자열은배열의형태로구현된응용자료형이므로연산을자유롭게할수없다. 배열에저장된문자열의길이를계산하는작업도간단하지않다.

More information

13 주차문자열의표현과입출력

13 주차문자열의표현과입출력 13 주차문자열의표현과입출력 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 C 언어를이용하여문자열을처리하기위해서는문자형의배열이나포인터를사용하게된다. 문자열을처리하는동작으로는단순하게문자열의입력이나출력기능이외에도문자열의복사나치환, 문자열의길이를구하거나문자열을비교하는기능등많은기능을필요로한다. 그러나이러한기능들을모두구현하기란매우까다로우며,

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 24. 파일입출력 2013.11.27. 오병우 컴퓨터공학과 파일 (File) 입출력 표준입출력 vs. 파일입출력 HDD 프로그래머입장에서는동일한방법으로입출력 다만 file 을읽고쓰기전에 Open 해서스트림에대한파일포인터 (file pointer) 를얻어야한다. OS 가실제작업을대행하며, 프로그래머는적절한함수를적절한방법으로호출 Department

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 전산 SMP 5 주차 2015. 10. 27 김범수 bskim45@gmail.com 들어가기전에 중간고사어땠나요? 점수는? Welcome to Array & Pointer = Hell! 지난내용복습 ~ 중간고사 자료형과형변환 연산자, 우선순위, 결합순서 산술연산자 : +,-, *, /, % 대입연산자 : =, +=, -=, *=, /=, %=,

More information

02장.배열과 클래스

02장.배열과 클래스 ---------------- DATA STRUCTURES USING C ---------------- CHAPTER 배열과구조체 1/20 많은자료의처리? 배열 (array), 구조체 (struct) 성적처리프로그램에서 45 명의성적을저장하는방법 주소록프로그램에서친구들의다양한정보 ( 이름, 전화번호, 주소, 이메일등 ) 를통합하여저장하는방법 홍길동 이름 :

More information

1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 #define _CRT_SECURE_NO_WARNINGS #include #include main() { char ch; printf(" 문자 1개를입력하시오 : "); scanf("%c", &ch); if (isalpha(ch))

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

Microsoft PowerPoint - 06_(C_Programming)_(Korean)_Characters_Strings

Microsoft PowerPoint - 06_(C_Programming)_(Korean)_Characters_Strings C Programming 문자와문자열 (Characters and Strings) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 문자처리 문자열처리 2 문자처리 문자처리 문자분류함수 문자변환함수 문자열처리 3 문자분류함수 (1/3) 문자분류 (Character classification) 함수 : 영문대소문자 영문대소문자로분류되는문자인지여부를확인하는함수

More information

Microsoft PowerPoint - a10.ppt [호환 모드]

Microsoft PowerPoint - a10.ppt [호환 모드] Structure Chapter 10: Structures t and Macros Structure 관련된변수들의그룹으로이루어진자료구조 template, pattern field structure를구성하는변수 (cf) C언어의 struct 프로그램의 structure 접근 entire structure 또는 individual fields Structure는

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures 단일연결리스트 (Singly Linked List) 신찬수 연결리스트 (linked list)? tail 서울부산수원용인 null item next 구조체복습 struct name_card { char name[20]; int date; } struct name_card a; // 구조체변수 a 선언 a.name 또는 a.date // 구조체 a의멤버접근 struct

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 12 표준입출력과파일입출력... 1. 표준입출력함수 2. 파일입출력함수 1. 표준입출력함수 표준입출력함수 표준입력 (stdin, Standard Input) : 키보드입력 표준출력 (stdout, StandardOutput) : 모니터출력 1. 표준입출력함수 서식화된입출력함수 printf(), scanf() 서식의위치에올수있는것들 [ 기본 11-1]

More information

윤성우의 열혈 TCP/IP 소켓 프로그래밊

윤성우의 열혈 TCP/IP 소켓 프로그래밊 윤성우저열혈강의 C 프로그래밍개정판 Chapter 21. 문자와문자열관련함수 Chapter 21-1. 스트림과데이터의이동 윤성우저열혈강의 C 프로그래밍개정판 무엇이입력이고무엇이출력인가 입력장치 출력장치 키보드 마우스 화상카메라 파일 모니터 프린터 입출력장치는매우포괄적이다. 데이터를컴퓨터내부로받아들이는것이입력이고외부로젂송하는것이출력이다. 데이터의이동수단이되는스트림

More information

11장 포인터

11장 포인터 쉽게풀어쓴 C 언어 Express 제 12 장문자와문자열 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것이다. 문자의중요성 인간한테텍스트는대단히중요하다.

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

Microsoft PowerPoint - chap03-변수와데이터형.pptx

Microsoft PowerPoint - chap03-변수와데이터형.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num %d\n", num); return 0; } 1 학습목표 의 개념에 대해 알아본다.

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

Microsoft PowerPoint - chap06-1Array.ppt

Microsoft PowerPoint - chap06-1Array.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-1 참고자료 배열 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 배열의선언과사용 같은형태의자료형이많이필요할때배열을사용하면효과적이다. 배열의선언 배열의사용 배열과반복문 배열의초기화 유연성있게배열다루기 한빛미디어

More information

untitled

untitled if( ) ; if( sales > 2000 ) bonus = 200; if( score >= 60 ) printf(".\n"); if( height >= 130 && age >= 10 ) printf(".\n"); if ( temperature < 0 ) printf(".\n"); // printf(" %.\n \n", temperature); // if(

More information

PowerPoint Template

PowerPoint Template 18 동적할당과고급처리 인터넷정보과 1 2/19 동적할당 목적 다음과같은일반변수의선언과사용은변수를정적 (static) 으로사용 int a = 10; 메모리사용예측이부정확한경우는충분한메모리를미리확보해야하는것은비효율 동적 (dynamic) 메모리할당 (Memory Allocation) 동적인메모리할당을위해서는함수 malloc() 을이용, 메모리공간을확보 함수 malloc()

More information

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조 - Part2- 제 2 장다차원배열이란무엇인가 학습목차 2.1 다차원배열이란 2. 2 2 차원배열의주소와값의참조 2.1 다차원배열이란 2.1 다차원배열이란 (1/14) 다차원배열 : 2 차원이상의배열을의미 1 차원배열과다차원배열의비교 1 차원배열 int array [12] 행 2 차원배열 int array [4][3] 행 열 3 차원배열 int array [2][2][3]

More information

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

Chapter_06

Chapter_06 프로그래밍 1 1 Chapter 6. Functions and Program Structure April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 문자의입력방법을이해한다. 중첩된 if문을이해한다. while 반복문의사용법을익힌다. do 반복문의사용법을익힌다.

More information

PA for SWE2007

PA for SWE2007 SWE2007: Software Experiment II (Fall 2014) Programming Assignment #0: Making own "string_sw.h" Due: 22nd Sep. (Mon), 11:59 PM 1. Introduction 이번과제에선, 앞으로있을다른과제들을수행하기위한필요할함수들을구현한다. 그대상은, 문자열조작 / 검사 / 변환함수들을담은

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 함수의인수 (argument) 전달방법 C 에서함수의인수전달방법 값에의한호출 (call-by-value): 기본적인방법 포인터에의한호출 (call-by-pointer): 포인터이용 참조에의한호출 (call-by-reference): 참조 (reference) 이용 7-35 값에의한호출 (call-by-value) 함수호출시에변수의값을함수에복사본으로전달 복사본이전달되며,

More information

Chapter 4. LISTS

Chapter 4. LISTS 연결리스트의응용 류관희 충북대학교 1 체인연산 체인을역순으로만드는 (inverting) 연산 3 개의포인터를적절히이용하여제자리 (in place) 에서문제를해결 typedef struct listnode *listpointer; typedef struct listnode { char data; listpointer link; ; 2 체인연산 체인을역순으로만드는

More information

3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터

3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터 - Part2-3 3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터 3.1 포인터란 ü ü ü. ü. ü. ü ( ) ? 3.1 ü. ü C ( ).? ü ü PART2-4 ü ( ) PART3-4 3.2 포인터변수의선언과사용 3.2 포인터 변수의 선언과 사용 (1/8) 포인터 변수의

More information

컴파일러

컴파일러 YACC 응용예 Desktop Calculator 7/23 Lex 입력 수식문법을위한 lex 입력 : calc.l %{ #include calc.tab.h" %} %% [0-9]+ return(number) [ \t] \n return(0) \+ return('+') \* return('*'). { printf("'%c': illegal character\n",

More information

Microsoft PowerPoint - chap11-1.ppt [호환 모드]

Microsoft PowerPoint - chap11-1.ppt [호환 모드] chapter 11-1 참고자료. 파일입출력 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr k 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- ehanbit.net 파일입출력의개념 파일은데이터를입출력하는모든대상을의미한다. - 키보드로부터데이터를입력하고모니터로출력하는것은키보드파일과 모니터파일로데이터를입출력하는것이다.

More information

Microsoft PowerPoint - chap4 [호환 모드]

Microsoft PowerPoint - chap4 [호환 모드] 제 5 장 C 표준라이브러리 숙대창병모 1 목표 C 표준라이브러리의깊이있는이해 시스템호출과 C 표준라이브러리관계 숙대창병모 2 C 입출력라이브러리함수 숙대창병모 3 시스템호출과라이브러리함수 System Calls well defined entry points directly into the kernel documented in section 2 of the

More information

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Example 3.1 Files 3.2 Source code 3.3 Exploit flow

More information

Microsoft PowerPoint - chap6 [호환 모드]

Microsoft PowerPoint - chap6 [호환 모드] 제 6 장프로세스 (Process) 숙대창병모 1 내용 프로세스시작 / 종료 명령중인수 / 환경변수 메모리배치 / 할당 비지역점프 숙대창병모 2 프로세스시작 / 종료 숙대창병모 3 Process Start Kernel exec system call user process Cstart-up routine call return int main(int argc,

More information

YRRZBRRLMCEQ.hwp

YRRZBRRLMCEQ.hwp C언어2 4차시강의자료 이대종( 한경대학교) 1 차시. 자료형( 데이터유형) 1.1 문자형데이터형식 ( char 형 ) 1.2 소수점이없는정수형 ( int 형 ) 1.3 소수점이있는실수형 (float 형, double 형 ) 2 차시. 연산자 2.1 2.2 2.3 2.4 산술연산자 증감연산자 관계연산자 논리연산자 3 차시. 제어문 ( 조건문, 반복문) 3.1

More information

PA for SWE2007

PA for SWE2007 Programming Assignment #0: Making own "my_string.h" SWE2007: Software Experiment II (Fall 2016) Due: 21st Sep. (Wed), 11:59 PM 1. Introduction 이번과제에선, 앞으로있을다른과제들을수행하기위한필요할함수들을구현한다. 그대상은, 문자열조작 / 검사 / 변환함수들을담은

More information

Microsoft PowerPoint - chap06-8 [호환 모드]

Microsoft PowerPoint - chap06-8 [호환 모드] 2011-1 학기프로그래밍입문 (1) 참고자료 chap 6-8. 메모리동적할당 박종혁 Tel: 970-6702 Email: jhpark1@seoultech.ac.kr h k 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- ehanbit.net 동적할당의필요성 프로그램을작성하는단계에서필요한기억공간의크기를결정하는 것은정적할당이다. - 변수나배열의선언

More information

Microsoft PowerPoint - chap-12.pptx

Microsoft PowerPoint - chap-12.pptx 쉽게풀어쓴 C 언어 Express 제 12 장문자와문자열 컴퓨터프로그래밍기초 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것이다. 컴퓨터프로그래밍기초 2

More information

Microsoft PowerPoint - chap06-8.ppt

Microsoft PowerPoint - chap06-8.ppt 2010-1 학기프로그래밍입문 (1) 참고자료 chap 6-8. 메모리동적할당 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 동적할당의필요성 프로그램을작성하는단계에서필요한기억공간의크기를결정하는것은정적할당이다. - 변수나배열의선언 프로그램의실행중에입력되는데이터에맞게기억공간을확보해야할때는동적할당이필요하다.

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것입니다. 2

이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것입니다. 2 제 12 장문자와문자열 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다.

More information

Infinity(∞) Strategy

Infinity(∞) Strategy 배열 (Array) 대용량데이터 대용량데이터를다루는기법 배열 (Array) 포인터 (Pointer) 구조체 (Structure) 파일 (File) 변수 (Variable) 변수및메모리할당 변수선언 : int imsi; imsi 4 Bytes 변수선언 : char imsi2; imsi2 1 Byte 배열 (Array) 배열 동일한데이터형을가지고있는데이터들을처리할때사용

More information

2007_2_project4

2007_2_project4 Programming Methodology Instructor: Kyuseok Shim Project #4: external sort with template Due Date: 0:0 a.m. between 2007-12-2 & 2007-12-3 Introduction 이프로젝트는 C++ 의 template을이용한 sorting algorithm과정렬해야할데이터의크기가

More information

Microsoft PowerPoint - 제11강 파일 처리

Microsoft PowerPoint - 제11강 파일 처리 제13장 파일 처리 파일열기 : File Open FILE *fp; fp=fopen( filename, r ); File handling mode: r, w, a, rb, wb, ab, r+, w+, a+ fclose(fp) 파일의종류 : Text File, Binary File Text file:.txt,.doc,.hwp Binary file:.exe,.jpg,.gif,.mov,.mpeg,.tif,.pgm,.ppm.

More information

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx Basic Idea of External Sorting run 1 run 2 run 3 run 4 run 5 run 6 750 records 750 records 750 records 750 records 750 records 750 records run 1 run 2 run 3 1500 records 1500 records 1500 records run 1

More information

Microsoft PowerPoint - 03_(C_Programming)_(Korean)_Pointers

Microsoft PowerPoint - 03_(C_Programming)_(Korean)_Pointers C Programming 포인터 (Pointers) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 포인터의이해 다양한포인터 2 포인터의이해 포인터의이해 포인터변수선언및초기화 포인터연산 다양한포인터 3 주소연산자 ( & ) 포인터의이해 (1/4) 변수와배열원소에만적용한다. 산술식이나상수에는주소연산자를사용할수없다. 레지스터변수또한주소연산자를사용할수없다.

More information

KNK_C_05_Pointers_Arrays_structures_summary_v02

KNK_C_05_Pointers_Arrays_structures_summary_v02 Pointers and Arrays Structures adopted from KNK C Programming : A Modern Approach 요약 2 Pointers and Arrays 3 배열의주소 #include int main(){ int c[] = {1, 2, 3, 4}; printf("c\t%p\n", c); printf("&c\t%p\n",

More information

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어 개나리 연구소 C 언어 노트 (tyback.egloos.com) 프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어먹고 하더라구요. 그래서,

More information

Microsoft PowerPoint - Chapter14_17.pptx

Microsoft PowerPoint - Chapter14_17.pptx Computer Engineering g Programming g 2 - 제 17 장동적메모리와연결리스트 - 제 14 장포인터활용 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적할당메모리 연결리스트 이중포인터 포인터배열 다차원배열과포인터 main

More information

Microsoft PowerPoint - Lesson14.pptx

Microsoft PowerPoint - Lesson14.pptx 2008 Spring Computer Engineering g Programming g 1 Lesson 14 - 제 17 장동적메모리와연결리스트 - 제14 장포인터활용 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적할당메모리 연결리스트 이중포인터

More information

Microsoft PowerPoint - Lesson14.pptx

Microsoft PowerPoint - Lesson14.pptx 2009 Spring Computer Engineering g Programming g 1 Lesson 14 - 제 17 장동적메모리와연결리스트 - 제14 장포인터활용 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적할당메모리 연결리스트 이중포인터

More information

Introduction to Geotechnical Engineering II

Introduction to  Geotechnical Engineering II Fundamentals of Computer System - chapter 9. Functions 민기복 Ki-Bok Min, PhD 서울대학교에너지자원공학과조교수 Assistant Professor, Energy Resources Engineering Last week Chapter 7. C control statements: Branching and Jumps

More information

Microsoft PowerPoint - 10장 문자열 pptx

Microsoft PowerPoint - 10장 문자열 pptx C 프로그래밍및실습 10. 문자열 세종대학교 목차 1) 문자열이란? 2) 문자열과포인터 3) 문자열의배열 4) 문자열처리함수 5) 문자열및문자입출력 2 1) 문자열이란 문자배열 ( 복습 ) 원소가문자인배열 각배열원소를하나의단위로처리 : 초기화, 입출력 char str[8] = {'H','e','l','l','o'}; // 문자로초기화 int i; for (i=0

More information

Microsoft PowerPoint - Chapter_08.pptx

Microsoft PowerPoint - Chapter_08.pptx 프로그래밍 1 1 Chapter 8. Pointers May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 포인터의개념 (1/6) 2 포인터란 : 다른객체를가리키는변수 객체의메모리주소를저장하는변수 기호적방식 (symbolic way) 으로주소사용 포인터와관련된연산자

More information

6.1 Addresses and Pointers Recall memory concepts from Ch2 ch6_testbasicpointer.c int x1=1, x2=7; double distance; int *p; int q=8; p = &q; name addre

6.1 Addresses and Pointers Recall memory concepts from Ch2 ch6_testbasicpointer.c int x1=1, x2=7; double distance; int *p; int q=8; p = &q; name addre GEN1031 Computer Programming Chapter 6 Pointer 포인터 Kichun Lee Department of Industrial Engineering Hanyang Univesity 1 6.1 Addresses and Pointers Recall memory concepts from Ch2 ch6_testbasicpointer.c

More information

1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문

1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문 1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문 1. 표준입출력 표준입출력 입력 : 키보드, scanf 함수 출력 : 모니터, printf 함수문제 : 정수값 2개를입력받고두값사이의값들을더하여출력하라. #include int main(void) int Num1, Num2; int

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600 균형이진탐색트리 -VL Tree delson, Velskii, Landis에의해 1962년에제안됨 VL trees are balanced n VL Tree is a binary search tree such that for every internal node v of T, the heights of the children of v can differ by at

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054>

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054> 의료프로그래밍실습 의료공학과이기영 1 Chap. 11 파일입출력 2 1 이장의목표 텍스트파일의입출력방법을익힌다. (284 쪽그림참조 ) 3 C 언어의파일종류 텍스트파일 (text file) 사람들이읽을수있는문자들을저장하고있는파일 텍스트파일에서 한줄의끝 을나타내는표현은파일이읽어들여질때, C 내부의방식으로변환된다. 이진파일 (binary file) : 자료형그대로의바이트수로연속해서저장

More information