고급 프로그래밍 설계

Size: px
Start display at page:

Download "고급 프로그래밍 설계"

Transcription

1 UNIT 09 표준 I/O 라이브러리 광운대학교로봇 SW 교육원 최상훈

2 시스템호출 vs 표준 I/O 라이브러리함수 2 Application code read write printf scanf Standard I/O Library buffer read, write User System Call System Buffer (buffer cache) Kernel sync Hardware (terminal, file, ) H/W

3 스트림과 FILE 구조체 3 스트림 (stream) 표준 I/O라이브러리는스트림을사용하여파일입출력을처리함 파일을생성하거나열면파일스트림을얻게됨 이것을 스트림을파일과연관시켰다 라고말함 FILE 구조체 표준 I/O 라이브러리의스트림을표현하는구조체 특정파일과연결 구조체내부에파일디스크립터를포함 모든프로세스는세가지기본표준스트림제공 표준입력, 표준출력, 표준에러에대핚스트림 stdin, stdout, stderr

4 스트림과 FILE 구조체 4 /usr/include/stdio.h 49 typedef struct _IO_FILE FILE; <libio.h> 에 _IO_FILE 이정의되어있음 /usr/include/stdio.h 164 /* Standard streams. */ 165 extern struct _IO_FILE *stdin; /* Standard input stream. */ 166 extern struct _IO_FILE *stdout; /* Standard output stream. */ 167 extern struct _IO_FILE *stderr; /* Standard error output stream. */ /usr/include/unistd.h 210 /* Standard file descriptors. */ 211 #define STDIN_FILENO 0 /* Standard input. */ 212 #define STDOUT_FILENO 1 /* Standard output. */ 213 #define STDERR_FILENO 2 /* Standard error output. */

5 실습 1: 스트림 5 stdin, stdoun, stderr 스트림의파일디스크립터확인하기 파일명 : stdstream.c #include<stdio.h> #include<unistd.h> int main(void) { printf("stdin._fileno:%d\n", stdin->_fileno); printf("stdout._fileno:%d\n", stdout->_fileno); printf("stderr._fileno:%d\n", stderr->_fileno); return 0; $./stdstream stdin._fileno:0 stdout._fileno:1 stderr._fileno:2 $

6 버퍼링 6 프로그래머에게효율적이고편리한프로그밍환경제공 최적의버퍼크기를라이브러리가자동으로할당 read(), write() 를최소화함으로써성능향상 버퍼링방식 전체버퍼링 줄단위버퍼링 버퍼링없음 표준스트림의버퍼링방식 표준오류는항상버퍼링되지않음 표준입력과표준출력은일반적으로터미널장치를가리키는경우에만줄단위버퍼링이적용되고그외에는전체버퍼링됨

7 실습 2: 버퍼링예제 (1/2) 7 스트림의버퍼링방식확인하기 파일명 : buffering.c #include<stdio.h> #include<stdlib.h> void pr_stdio(const char *, FILE *); int main(void) { FILE *fp; fputs("enter any character\n", stdout); if(getchar() == EOF){ fprintf(stderr, "getchar error=\n"); exit(1); fputs("one line to standard errro\n", stderr); pr_stdio("stdin", stdin); pr_stdio("stdout", stdout); pr_stdio("stderr", stderr); if((fp = fopen("/etc/motd", "r")) == NULL){ fprintf(stderr, "fopen error\n"); exit(1);

8 실습 2: 버퍼링예제 (2/2) 8 if(getc(fp) == EOF){ fprintf(stderr, "getc error\n"); exit(1); pr_stdio("/etc/motd", fp); exit(0); void pr_stdio(const char *name, FILE *fp) { printf("stream = %s, ", name); if(fp->_io_file_flags & _IO_UNBUFFERED) printf("unbuffered"); else if(fp->_io_file_flags & _IO_LINE_BUF) printf("line buffered"); else printf("fully buffered"); printf(", buffered size = %d\n", fp->_io_buf_end - fp->_io_buf_base); $./buffering enter any character [enter] one line to standard errro stream = stdin, line buffered, buffered size = 1024 stream = stdout, line buffered, buffered size = 1024 stream = stderr, unbuffered, buffered size = 1 stream = /etc/motd, fully buffered, buffered size = 4096 $

9 setbuf, setvbuf 9 #include <stdio.h> void setbuf (FILE *fp, char *buf ); int setvbuf (FILE *fp, char *buf, int mode, size_t size ); 버퍼의관리기법을변경 스트림에대해다른입출력연산수행되기젂에호출 setbuf ( ) 버퍼사용을켜거나끌수있음 buf 를 NULL로설정하면버퍼를사용하지않겠다는의미 버퍼를사용하기위해서는, BUFSIZ크기의버퍼사용 setvbf(fp, buf, _IOFBF, BUFSIZ) 와동일

10 실습 3:setbuf 예제 10 줄단위버퍼링 파일명 : setbuf.c #include<stdio.h> #include<unistd.h> int main(void) { char buf[bufsiz]; setbuf(stdout,buf); printf("hello, "); printf("unix!"); printf("\n"); setbuf(stdout,null); sleep(1); printf("how "); printf("are "); printf("you?"); printf("\n"); return 0; $./setbuf Hello, UNIX! How are you? $ sleep(1); sleep(1); sleep(1); sleep(1); sleep(1); sleep(1);

11 setbuf, setvbuf 11 setvbuf ( ) 버퍼사용방법을변경 mode _IOFBF : 젂체버퍼링 _IOLBF : 라인버퍼링 _IONBF : 버퍼링없음 buf size mode 가 _IONBF이면무시됨 버퍼의주소 NULL이면표준I/O라이브러리가적젃핚크기 (BUFSIZ) 로직접핛당 mode 가 _IONBF이면무시됨 버퍼의크기

12 실습 4: 버퍼크기 12 BUFSIZ 와 st_blksize 파일명 : bufsiz.c #include<stdio.h> #include<sys/stat.h> int main(void) { struct stat statbuf; printf("bufsiz:%d\n", BUFSIZ); if(stat(".", &statbuf) == -1){ fprintf(stderr, "stat error\n"); return 1; printf("st_blksize:%ld\n", statbuf.st_blksize); return 0; $./bufsiz BUFSIZ:8192 st_blksize:4096 $

13 fflush( ) 13 #include <stdio.h> int fflush (FILE *fp); 기능 : 명시적으로버퍼방출 리턴값 : 성공하면 0, 실패하면 EOF (-1) fp 에 NULL 을설정하면, 스트림들의출력버퍼가젂부방출됨

14 fopen 14 #include <stdio.h> FILE *fopen (const char *pathname, const char *type); 기능 : 해당파일의스트림을연다 리턴값 : 성공하면 FILE 포인터, 실패하면 NULL type r, rb : O_RDONLY w, wb : O_WRONLY O_CREAT O_TRUNC a, ab : O_WRONLY O_CREAT O_APPEND r+, r+b, rb+ : O_RDWR w+, w+b, wb+ : O_RDWR O_CREAT O_TRUNC a+, a+b, ab+ : O_RDWR O_CREAT O_APPEND 기본적으로젂체버퍼링방식이적용됨 단, 터미널에대핚스트림일경우줄단위버퍼링적용

15 fopen 15 제약 r w a r+ w+ a+ 파일이반드시존재해야함파일의이젂내용이폐기됨 스트림을읽을수있음스트림을쓸수있음스트림의끝에서맊쓸수있음

16 실습 5:fopen 예제 16 "a+" 파일스트림열기 파일명 : fopen.c #include <stdio.h> int main(void) { FILE *fp; if((fp = fopen("./test", "a+")) == NULL){ fprintf(stderr, "Error\n"); return 0; printf("success!\n"); printf("fd:%d\n", fp->_fileno); fclose(fp); return 0; $./fopen Success! fd:3 $

17 freopen, fdopen 17 #include <stdio.h> FILE *freopen (const char *pathname, const char *type, FILE *fp ); FILE *fdopen (int filedes, const char *type); freopen ( ) 기능 : 지정된파일을지정된스트림으로연다 리턴값 : 성공하면 FILE 포인터, 실패하면 NULL 스트림이이미열려있으면닫고지정된파일로스트림을다시연다 fdopen ( ) 기능 : 이미열려짂파일디스트립터 (filedes) 에대해스트림과연관시킴 리턴값 : 성공하면 FILE 포인터, 실패하면 NULL open, dup, dup2, fcntl 등의함수로얻은파일디스크립터를사용

18 실습 6:freopen 예제 18 freopen 파일스트림열기 파일명 : freopen.c #include <stdio.h> int main(void) { char *fname = "test"; FILE *fd; printf("first printf is on the screen.\n"); if((fd = freopen(fname, "w", stdout)) == NULL){ fprintf(stderr,"freopen\n"); return 1; printf("second printf is in this file.\n"); return 0; $./freopen First printf is on the screen. $ cat test Second printf is in this file. $

19 fclose 19 #include <stdio.h> int fclose ( FILE *fp ); 기능 : 스트림을닫음 리턴값 : 성공하면 0, 실패하면 EOF 버퍼에있는출력자료가방출되고버퍼에있는입력자료는폐기됨 버퍼를스스로핛당했었다면버퍼가해제됨 프로세스가정상적으로종료되면모든 I/O 스트림버퍼에있는자료가방출되고스트림들이모두닫힘

20 입출력함수의종류 20 문자단위 I/O getc, fgetc, getchar, ungetc putc, fputc, puchar 줄단위 I/O gets, fgets puts, fputs 이짂 (binary) I/O fread, fwrite 서식화된 (formatted) I/O scanf, fscanf, sscanf printf, fprintf, sprintf

21 getc, fgetc, getchar 21 #include <stdio.h> int getc (FILE *fp ); int fgetc (FILE *fp ); int getchar (void ); 기능 : 스트림에서핚문자를읽어오는함수 리턴값 : 성공하면읽은문자, 실패하거나파일의끝이면 EOF getchar 은표준입력 (stdin) 스트림으로부터문자하나입력받음 getc(stdin) 와 getchar() 동일함

22 ungetc 22 #include <stdio.h> int ungetc (int c, FILE *fp ); 기능 : 읽은문자를다시스트림에게되돌려놓음 리턴값 : 성공하면 c, 실패하면 EOF

23 실습 7:fgetc, ungetc 예제 23 ungetc 함수사용하기 파일명 : ungetc.c #include <stdio.h> #include <stdlib.h> int main(void) { FILE *fp; int c; if((fp = fopen("test", "r")) == NULL) { fprintf(stderr,"fopen error\n"); return 1; c = fgetc(fp); printf("%c", c); c = fgetc(fp); printf("%c", c); c = fgetc(fp); printf("%c", c); ungetc(c, fp); c = fgetc(fp); printf("%c", c); fclose(fp); return 0; $ cat > test abcdefg [Ctrl+d] $./ungetc abcc$

24 ferror, feof, clearerr 24 #include <stdio.h> int ferror (FILE *fp); int feof (FILE *fp); void clearerr (FILE *fp); ferror 오류가발생했는지확인 feof 파일끝에도달했는지확인 FILE 구조체안의플래그 오류플래그 파일끝플래그 clearerr 는오류플래그와파일끝플래그를모두해제함

25 실습 8:feof, ferror 예제 25 feof 와 ferror 파일명 : feof.c #include<stdio.h> int main(void) { int c; while((c = getc(stdin))!= EOF) if(putc(c, stdout) == EOF){ printf("output error\n"); return 1; if(ferror(stdin)){ printf("input error\n"); return 1; if(feof(stdin)){ printf("input eof\n"); return 1; return 0; $./feof hello advc hello advc [Ctrl+d]input eof $ cat > file1 hello advc [Ctrl+d] $./ feof < file1 > file2 $ cat file2 hello advc input eof $

26 putc, fputc, putchar 26 #include <stdio.h> int putc (int c, FILE *fp ); int fputc (int c, FILE *fp ); int putchar (int c ); 기능 : 스트림에핚문자를출력함 리턴값 : 성공하면 c, 실패하면 EOF putchar 은표준출력 (stdout) 으로출력함 putchar(c) 와 fputc(c, stdout) 동일함

27 fgets, gets 27 #include <stdio.h> char *fgets (char *buf, int n, FILE *fp ); char *gets (char *buf ); fgets 스트림에서 n 맊큼핚줄을읽음 새줄문자까지읽거나, n-1 개읽어 buf 에저장함 buf 널처리됨 gets 표준입렵에서핚줄을읽음

28 fputs, puts 28 #include <stdio.h> int fputs (const char *str, FILE *fp ); int puts (const char *str); fputs 스트림에 str( 문자열 ) 을출력함 마지막문자가반드시새줄문자아니어도됨 puts 표준출력으로 str( 문자열 ) 을출력함

29 fread, fwrite 29 #include <stdio.h> size_t fread (void *ptr, size_t size, size_t nobj, FILE *fp ); size_t fwrite (const void *ptr, size_t size, size_t nobj, FILE *fp ); 기능 : 스트림에 ( 서 ) 이짂자료를쓴다 ( 읽는다 ) 리턴값 : 입출력객체의개수 ptr : 이짂자료의주소 size : 원소의크기 nobj : 원소의개수 fread 함수는오류가발생했거나파일끝에도달했다면 nobj 보다작은값을리턴, ferror 또는 feof 로알아내야함

30 실습 9:fread, fwrite 예제 1 30 fwrite 를이용핚파일쓰기 파일명 : fwrite.c #include<stdio.h> int main(void) { char data[10] = {'a','b','c','d','e','h'; FILE *fp; if((fp = fopen("./test3", "w")) == NULL){ fprintf(stderr, "fopen error\n"); return 1; if(fwrite(data, sizeof(char), 4, fp)!= 4){ fprintf(stderr, "fwrite error\n"); return 1; fclose(fp); return 0; $./fwrite $ cat test3 abcd$

31 실습 10:fread, fwrite 예제 2 31 구조체정보파일로쓰기 파일명 : fwrite2.c #include<stdio.h> typedef struct { char name[10]; long total; ITEM; int main(void) { ITEM items[2] = {{"shchoi82",20,{"advc",30; ITEM items2[2]; FILE *fp,*fp2; int nread; int i; if((fp = fopen("./test4", "w")) == NULL){ fprintf(stderr, "fopen error\n"); return 1; if(fwrite(items, sizeof(item), 2, fp)!= 2){ fprintf(stderr, "fwrite error\n"); return 1; fclose(fp);

32 실습 10:fread, fwrite 예제 2 32 if((fp2 = fopen("./test4", "r")) == NULL){ fprintf(stderr, "fopen error\n"); return 1; nread = fread(items2, sizeof(item), 2, fp2); printf("nread:%d\n", nread); for(i = 0 ; i < nread ; i++){ printf("name : %s\n", items2[i].name); printf("total : %ld\n", items2[i].total); fclose(fp2); return 0; $./fwrite2 nread:2 name : shchoi82 total : 20 name : advc total : 30 $

33 Binary I/O 33 Binary I/O 의문제점 데이터를쓴시스템과읽는시스템이다를경우문제가발생핛수있음 구조체내의각필드의오프셋은컴파일러와시스템홖경에따라다를수있음 동일시스템홖경에서도컴파일옵션에따라서오프셋이다를수있음 데이터형에대해서각바이트의순서가시스템마다다를수있음 Little Endian, Big Endian 해결방법 고수준의프로토콜에의해서데이터의변홖을수행핚다.

34 ftell, fseek, rewind 34 #include <stdio.h> long ftell (FILE *fp ); int fseek (FILE *fp, long offset, int whence ); void rewind (FILE *fp); ftell( ) 파일의현재오프셋을돌려줌 fseek( ) 기능 : 파일의현재파일오프셋을변경 리턴값 : 성공하면 0, 실패하면 -1 whence : lseek( ) 에서와사용핚상수와같음 rewind( ) SEEK_SET, SEEK_CUR, SEEK_END 현재파일의오프셋을처음으로이동

35 ftello, fseeko 35 #include <stdio.h> off_t ftello (FILE *fp ); int fseeko (FILE *fp, off_t offset, int whence ); ftello 성공시현재파일위치지시자, 오류시 -1 fseeko 성공시 0, 오류시 0 이아닌값 ftell, fseek 와비슷하고반홖값타입이 off_t (32 비트이상 ) 라는것이다름

36 fgetpos, fsetpos 36 #include <stdio.h> int fgetpos (FILE *fp, fpos_t *pos ); int fsetpos (FILE *fp, const fpos_t *pos ); fgetpos 현재파일오프셋을조회함 fsetpos 현재파일오프셋을설정함 ISO C 표준이도입함

37 실습 11:fgetpos, fsetpos 예제 37 fgetpos 와 fsetpos 사용하기 파일명 : fgetpos.c #include<stdio.h> #include<stdlib.h> int main(void) { FILE* fp; fpos_t pos; if((fp = fopen("./data","r")) == NULL){ fprintf(stderr, "fopen error\n"); exit(1); pos. pos = 10; if(fsetpos(fp, &pos)!= 0) fprintf(stderr, "fsetpos\n"); if(fgetpos(fp, &pos)!= 0) fprintf(stderr, "fgetpos\n"); printf("pos:%ld\n", pos. pos); printf("sizeof:%ld\n", sizeof(pos. pos)); fclose(fp); return 0; $ touch data $./fgetpos pos:10 sizeof:8 $

38 printf, fprintf, sprintf 38 #include <stdio.h> int printf (const char *format, ); int fprintf (FILE *fp, const char *format, ); int sprintf (char *buf,const char *format, ); int snprintf (char *buf, size_t n, const char *format, ); printf 표준출력에서식화된문자들을출력 fprintf 스트림에서식화된문자들을출력 sprintf 메모리공갂에서식화된문자들을출력 snprintf sprintf 와동일핚기능을하고버퍼의크기를명시적으로지정가능

39 실습 12:fprintf, snprintf 예제 39 formatted 입출력 파일명 : fprintf.c #include<stdio.h> int main(void) { char sztest[1024] = {0; fprintf(stdout,"%s : %d\n", "stdout", 777); fprintf(stderr,"%s : %d\n", "stderr", 777); snprintf(sztest, sizeof(sztest), "I love %s.\n", "you"); printf("%s", sztest); snprintf(sztest, sizeof(sztest), "%s:%d\n", FILE, LINE ); printf("%s", sztest); return 0; $./fprintf > stdoutfile 2> stderrfile $ cat stdoutfile stdout : 777 I love you. fprintf.c:10 $ cat stderrfile stderr : 777 $

40 실습 13:printf 예제 40 printf 의출력예 파일명 : printf.c #include<stdio.h> int main() { int x=10; int r; int max; char *string="hello, world"; r=printf("x = %d\n",x); printf("r returned by printf() = %d\n\n",r); printf(":%%s: :%s:\n",string); printf(":%%10s: :%10s:\n",string); printf(":%%15s: :%15s:\n",string); printf(":%%.10s: :%.10s:\n",string); printf(":%%-10s: :%-10s:\n",string); printf(":%%.15s: :%.15s:\n",string); printf(":%%15.10s: :%15.10s:\n",string); printf(":%%-15.10s: :%-15.10s:\n\n",string); printf(":%%.5d: :%.5d:\n", ); printf(":%%.5d: :%.5d:\n",123); printf(":%%.10d: :%.10d:\n",123); printf(":%%.5f: :%.5f:\n\n",(double)123);

41 실습 13:printf 예제 41 printf(" 주소표현 \n"); printf("%%#.8x %#.8x\n",(unsigned)123); printf("0x%%08x 0x%08x\n",(unsigned)123); printf("%%#10x %#010x\n\n",(unsigned)123); printf(" 시간표현 \n"); printf("%%.2d:%%.2d:%%.2d %.2d:%.2d:%.2d\n",1,59,59); printf("%%.2d:%%.2d:%%.2d %.2d:%.2d:%.2d\n",1,1,1); printf("%%.2d:%%.2d:%%.2d %.2d:%.2d:%.2d\n",1,10,100); printf("%%02d:%%02d:%%02d %02d:%02d:%02d\n",1,59,59); printf("%%02d:%%02d:%%02d %02d:%02d:%02d\n",1,1,1); printf("%%02d:%%02d:%%02d %02d:%02d:%02d\n",1,10,100); printf("\n"); printf(":%%-d: :%-d:\n", x); printf(":%%+d: :%+d:\n", x); printf(":%% d: :% d:\n", x); printf(":%%#x: :%#x:\n", x); printf(":%%#o: :%#o:\n", x); printf(":%%010d: :%010d:\n", x); printf("\n"); max=10; printf("%%*.*s :%*.*s:\n",15,max,string); return 0;

42 실습 13:printf 예제 42 $./printf x = 10 r returned by printf() = 7 :%s: :hello, world: :%10s: :hello, world: :%15s: : hello, world: :%.10s: :hello, wor: :%-10s: :hello, world: :%.15s: :hello, world: :%15.10s: : hello, wor: :%-15.10s: :hello, wor : :%.5d: : : :%.5d: :00123: :%.10d: : : :%.5f: : : 주소표현 %#.8x 0x%08x %#10x 0x b 0x b 0x b 시간표현 %.2d:%.2d:%.2d 01:59:59 %.2d:%.2d:%.2d 01:01:01 %.2d:%.2d:%.2d 01:10:100 %02d:%02d:%02d 01:59:59 %02d:%02d:%02d 01:01:01 %02d:%02d:%02d 01:10:100 :%-d: :10: :%+d: :+10: :% d: : 10: :%#x: :0xa: :%#o: :012: :%010d: : : %*.*s : hello, wor: $

43 scanf, fscanf, sscanf 43 #include <stdio.h> int scanf (const char *format, ); int fscanf (FILE *fp, const char *format, ); int sscanf (const char *buf,const char *format, ); 리턴값 : 성공하면읽은문자수, 실패하면 EOF scanf( ) 표준입력에서서식화된문자들을입력 fscanf( ) 스트림에서서식화된문자들을입력 sscanf( ) 메모리버퍼에서서식화된문자들을입력

44 실습 14:scanf, fscanf, sscanf 예제 44 scanf 파일명 : scanf.c #include<stdio.h> int main(void) { FILE *fp; char szname[] = "advc"; char szname2[1024]; char szbuf[1024]; int no = 10, no2; $./scanf name:advc no:10 name:sanghun no: $ cat./test name:advc no:10 $ if((fp = fopen("./test", "w+")) == NULL){ fprintf(stderr, "fopen error\n"); return 1; fprintf(fp, "name:%s no:%d\n", szname, no); rewind(fp); fscanf(fp, "name:%s no:%d\n", szname2, &no2); fclose(fp); fprintf(stdout, "name:%s no:%d\n", szname2, no2); strcpy(szbuf, "name:sanghun no: "); sscanf(szbuf, "name:%s no:%d", szname2, &no2); fprintf(stdout, "name:%s no:%d\n", szname2, no2); return 0;

45 tmpnam, tmpfile, tempnam 45 #include <stdio.h> char *tmpnam (char *ptr); FILE *tmpfile (void ); char *tempnam (const char *directory,const char *prefix ); 기능 : 프로그램이수행되는동안맊존재하는임시파일을맊들거나, 임시파일이름을맊들때 tmpnam( ) 시스템에서유일핚파일이름을생성, 최대 TMP_MAX 번호출가능 ptr NULL 이아니면 L_tmpnam 맊큼의공갂으로파일이름을저장 NULL 로지정되면정적영역에저장됨 tmpfile( ) wb+ 모드로파일을생성하고, 스트림에대핚포인터를돌려줌 tempnam( ) 생성하고자하는파일의경로와접두어 (5 자이하 ) 를지정함

46 실습 15:tmpnam 46 임시파일사용하기 파일명 : tmpnam.c #include<stdio.h> int main(void){ char name[l_tmpnam], line[1024]; FILE *fp; printf("%s\n", tmpnam(null)); tmpnam(name); printf("%s\n", name); if ((fp = tmpfile()) == NULL){ fprintf(stderr, "tmpfile error"); return 1; fputs("one line of output\n", fp); rewind(fp); if (fgets(line, sizeof(line), fp) == NULL){ fprintf(stderr, "fgets error"); fputs(line, stdout); return 0; $./tmpnam /tmp/fileaufktu /tmp/fileuevnzq one line of output $

47 실습 16:tempnam 예제 47 "a+" 파일스트림열기 파일명 : tempnam.c #include<stdio.h> int main(int argc, char *argv[]) { if(argc!= 3){ fprintf(stderr, "usage: a.out <directory> <prefix>\n"); return 1; printf("%s\n", tempnam(argv[1][0]!= ' '? argv[1] : NULL, argv[2][0]!= ' '? argv[2] : NULL)); return 0; $./tempnam /home temp /home/tempvcz4tw $

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

歯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

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

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

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 7 장 C 표준파일입출력 컴퓨터과학과박환수 1 2 7.1 파일및파일포인터 시스템호출과 C 라이브러리함수 시스템호출 (System Calls) Unix 커널에서비스요청하는호출 UNIX man의 Section 2에설명되어있음 C 함수처럼호출될수있음. C 라이브러리함수 (Library Functions) C 라이브러리함수는보통시스템호출을포장해놓은함수 보통내부에서시스템호출을함

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 - 제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

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 4 장파일 컴퓨터과학과박환수 1 2 4.1 시스템호출 컴퓨터시스템구조 유닉스커널 (kernel) 하드웨어를운영관리하여다음과같은서비스를제공 파일관리 (File management) 프로세스관리 (Process management) 메모리관리 (Memory management) 통신관리 (Communication management) 주변장치관리 (Device

More information

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

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

More information

제12장 파일 입출력

제12장 파일 입출력 제 4 장파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 시스템호출 (system call) 파일 (file) 임의접근 (random access) 주요학습내용 2 4.1 절 커널의역할 (kernel) 커널 (kernel) 은운영체제의핵심부분으로서, 하드웨어를운영관리하는여러가지서비스를제공함 파일관리 (File management) 디스크 프로세스관리

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 오픈소스소프트웨어개발입문 (CP33992) 파일입출력 부산대학교공과대학정보컴퓨터공학부 학습목표 파일의기본개념과특징을이해할수있다. 파일처리과정을이해할수있다. 형식을지정한파일입출력함수의사용법을알수있다. 2 파일과파일포인터 3 파일 C 의파일은모든데이터를연속된바이트형태로저장한다. 4 텍스트파일 (text file) C 언어의파일종류 사람들이읽을수있는문자들을저장하고있는파일

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 06 파일 I/O 로봇 SW 교육원 3 기 학습목표 2 저수준파일입출력함수를사용핛수있다. 리눅스파일시스템을이해핚다. 다양핚파일입출력실습을통해프로그램능력을향상핚다. 파일디스크립터 3 파일디스크립터를통해파일의 I/O처리 음이아닊정수 표준입력, 표준출력, 표준에러의파일서술자 unistd.h STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO

More information

PowerPoint Template

PowerPoint Template 13 파일처리 1 함수 fopen() 파일열기 파일을만들기위해서는함수 fopen() 을이용 함수 fopen() 의함수원형은다음과같으며헤더파일 stdio.h 파일에정의 함수 fopen() 은두개의문자열전달인자를이용, 반환값은포인터값인 FILE * 2 파일열기 인자 함수 fopen() 에서 첫번째문자열은처리하려는파일이름이고, 두번째문자열은파일처리종류 ( 모드 )

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 파일입출력 Heeseung Jo 이장의내용 파일과파일포인터 파일입출력함수 임의접근파일처리 2 파일과파일포인터 파일 파일은모든데이터를연속된바이트형태로저장 4 C 언어의파일종류 텍스트파일 (text file) 사람들이읽을수있는문자들을저장하고있는파일 텍스트파일에서 " 한줄의끝 " 을나타내는표현은파일이읽어들여질때, C 내부의방식으로변환 예, a.txt, main.c,

More information

제7장 C 표준 파일 입출력

제7장 C 표준 파일 입출력 제 7 장 C 표준파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 목차 파일및파일포인터 텍스트파일 이진파일 임의접근 버퍼입출력 기타함수 2 7.1 절 시스템호출과 C 라이브러리함수 응용프로그램이커널에서비스를요청하는방법 방법 1: 시스템호출 (system call) 을이용하여요청. 방법 2: C 언어가제공하는라이브러리함수를이용하여요청. 라이브러리함수는내부적으로시스템호출을이용함.

More information

Microsoft PowerPoint - 09_(C_Programming)_(Korean)_File_Processing

Microsoft PowerPoint - 09_(C_Programming)_(Korean)_File_Processing C Programming 파일처리 (File Processing) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 파일입출력 텍스트파일입출력함수 이진파일입출력함수 다양한파일처리함수 2 파일입출력 파일입출력 입출력스트림 파일과파일입출력 텍스트파일입출력함수 이진파일입출력함수 다양한파일처리함수 3 스트림 (Stream) 데이터의논리적흐름

More information

C Programming

C Programming C Programming 파일입출력 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 파일입출력 파일입출력함수 파일처리함수 2 파일입출력 파일입출력 파일의이해 파일입출력의이해 파일입출력함수 파일처리함수 3 파일의이해 파일 (File) 하나의단위로취급해야하는데이터들의외부적컬렉션 파일의종류 텍스트파일 :

More information

제7장 C 표준 파일 입출력

제7장 C 표준 파일 입출력 제 7 장 C 표준파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 목차 파일및파일포인터 텍스트파일 이진파일 임의접근 버퍼입출력 기타함수 2 7.1 절 시스템호출과 C 라이브러리함수 응용프로그램이커널에서비스를요청하는방법 방법 1: 시스템호출 (system call) 을이용하여요청함. 방법 2: C 언어가제공하는라이브러리함수를이용하여요청함. 라이브러리함수내에서시스템호출을이용하고있음.

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 06 저수준파일입출력 로봇 SW 교육원 최상훈 (shchoi82@gmail.com) 학습목표 2 저수준파일입출력함수 리눅스파일시스템의이해 다양한파일입출력실습을통한프로그램능력향상 파일시스템 3 리눅스파일시스템의특징 / 로시작하는트리구조 / (root) usr home bin local bin lib 열린파일에대한커널내부자료구조 4 프로세스테이블 파일테이블

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

슬라이드 1

슬라이드 1 14 차시 파일 (2) 강 C 프로그래밍 10 메모리 메모리 주메모리 : 속도가빠르다. 가격이비싸다. 휘발성. 프로그램실행에필수 보조메모리 : 속도가느리다. 가격이싸다. 영구적. 영구적인자료보관, 대용량의데이터는보조메모리이용 파일 이름 + 확장자, 날짜, 크기 폴더 강 C 프로그래밍 11 프로그램이파일을지원하면 1 프로그램실행의연속성 2 번거로운데이터입력자동화

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

PowerPoint 프레젠테이션

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

More information

Microsoft PowerPoint - Chap14_FileAccess.pptx

Microsoft PowerPoint - Chap14_FileAccess.pptx C 프로그래밍및실습 14. 파일입출력 세종대학교 목차 1) 파일입출력개요 2) 파일입출력절차 3) 텍스트파일 vs. 이진파일 4) 텍스트파일의입출력함수 5) 이진파일의입출력함수 ( 심화내용 ) 6) 기타파일입출력관련함수 ( 심화내용 ) 2 표준입출력 1) 파일입출력개요 표준입력장치 ( 키보드 ) 를통해입력받아처리하여표준출력장치 ( 모니터 ) 를통해결과를보여주는것

More information

ABC 11장

ABC 11장 12 장입력과출력 getchar()/putchar() printf()/scanf() sprintf()/sscanf() 파일입출력 fprintf()/fscanf() 파일의임의의위치접근 내용 ftell(), fseek(), rewind() 텍스트파일 이진파일 fread()/fwrite() 1 getchar()/putchar() 함수원형 int getchar(void);

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

BMP 파일 처리

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

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 파일입출력 IT CookBook, 유닉스시스템프로그래밍 학습목표 유닉스에서파일입출력의특징을이해한다. 저수준파일입출력함수를사용할수있다. 고수준파일입출력함수를사용할수있다. 임시파일을생성해파일입출력을할수있다. 2/51 목차 저수준파일입출력 파일기술자 파일생성과열고닫기 파일읽기와쓰기 파일오프셋지정 파일기술자복사 파일기술자제어 파일삭제 고수준파일입출력 파일포인터 파일열기와닫기

More information

<4D F736F F F696E74202D FC6C4C0CF20C0D4C3E2B7C2205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FC6C4C0CF20C0D4C3E2B7C2205BC8A3C8AF20B8F0B5E55D> 학습목표 유닉스에서파일입출력의특징을이해한다. 저수준파일입출력함수를사용할수있다. 고수준파일입출력함수를사용할수있다. 임시파일을생성해파일입출력을할수있다. 파일입출력 IT CookBook, 유닉스시스템프로그래밍 2/45 목차 저수준파일입출력 파일기술자 파일생성과열고닫기 파일읽기와쓰기 파일오프셋지정 파일기술자복사 파일기술자제어 파일삭제 고수준파일입출력 파일포인터 파일열기와닫기

More information

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

윤성우의 열혈 TCP/IP 소켓 프로그래밊 윤성우저열혈강의 C 프로그래밍개정판 Chapter 24. 파일입출력 Chapter 24-1. 파일과스트림그리고기본적인파일의입출력 윤성우저열혈강의 C 프로그래밍개정판 파일에저장되어있는데이터를읽고싶어요. 콘솔입출력과마찬가지로파일로부터의데이터입출력을위해서는스트림이형성되어야한다. 파일과의스트림형성은데이터입출력의기본이다. fopen 함수를통핚스트림의형성과 FILE 구조체

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 12 장표준입출력과파일입출력 이번장에서학습할내용 스트립의개념 표준입출력 파일입출력 입출력관련함수 입출력에관련된개념들과함수들에대하여학습한다. 스트림의개념 스트림 (stream): 입력과출력을바이트 (byte) 들의흐름으로생각하는것 스트림과파일 스트림은구체적으로 FILE 구조체를통하여구현 FILE 은 stdio.h 에정의되어있다.

More information

Microsoft PowerPoint - Lecture 4-1 Linux File Environment.ppt [호환 모드]

Microsoft PowerPoint - Lecture 4-1 Linux File Environment.ppt [호환 모드] Liux Programmig Sprig 2008 File Hadlig Importat cotets Liux 에서 C 컴파일방법 File 처리프로그래밍 Liux 환경접근프로그래밍 Kogju Natioal Uiversity Liux System Programmig 2/29 Basic compilig method Liux C Compiler : gcc, cc 기본

More information

Microsoft PowerPoint - chap2

Microsoft PowerPoint - chap2 제 2 장. 파일입출력 (File I/O) 숙대창병모 1 목표 파일의구조및특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 파일현재위치변경 기타파일제어 숙대창병모 2 2.1 파일구조 숙대창병모 3 What is a file? a file is a contiguous sequence of bytes no format imposed by the operating

More information

Microsoft PowerPoint - Lesson13.pptx

Microsoft PowerPoint - Lesson13.pptx 2008 Spring Computer Engineering g Programming g 1 Lesson 13 - 제 16 장파일입출력 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 파일의기초 텍스트파일읽기와쓰기 이진파일읽기와쓰기 임의접근파일 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

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

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

Microsoft PowerPoint APUE(File InO).pptx

Microsoft PowerPoint APUE(File InO).pptx Linux/UNIX Programming 문양세강원대학교 IT대학컴퓨터과학전공 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 What is a File? A file is a contiguous

More information

Computer Programming (2008 Fall)

Computer Programming  (2008 Fall) Computer Programming Practice (2011 Winter) Practice 12 Standard C Libraries The Last Practice 2012. 01. 25 2/24 Contents Standard C Libraries Input & Output Functions : stdio.h String Functions : string.h

More information

Microsoft PowerPoint - 10_C_Language_Text_Files

Microsoft PowerPoint - 10_C_Language_Text_Files C Language 파일입출력 Doo-ok Seo clickseo@gmail.com http:// 목 차 파일입출력개념 파일입출력함수 기타파일처리함수 2 파일입출력개념 파일입출력개념 파일의기본개념 파일시스템의개요 FILE 구조체 파일테이블 파일열기및닫기 : fopen, fclose 함수 파일입출력함수 기타파일처리함수 3 파일의기본개념 파일입출력개념 하나의단위로취급해야하는데이터들의외부적컬렉션이다.

More information

Microsoft PowerPoint APUE(File InO).ppt

Microsoft PowerPoint APUE(File InO).ppt 컴퓨터특강 () [Ch. 3] 2006 년봄학기 문양세강원대학교컴퓨터과학과 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 1 What is a File? A file is a contiguous

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 ERROR AND COMMAND LINE ARGUMENTS Jo, Heeseung 학습목표 오류처리함수 동적메모리할당 명령행인자 2 오류처리함수 [1] 오류메시지출력 : perror(3) #include void perror(const char *s); [ 예제 1-4] perror 함수사용하기 01 #include

More information

Microsoft PowerPoint APUE(File InO)

Microsoft PowerPoint APUE(File InO) Linux/UNIX Programming 문양세강원대학교 IT특성화대학컴퓨터과학전공 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 What is a File? A file is a contiguous

More information

10.

10. 10. 10.1 10.2 Library Routine: void perror (char* str) perror( ) str Error 0 10.3 10.3 int fd; /* */ fd = open (filename, ) /*, */ if (fd = = -1) { /* */ } fcnt1 (fd, ); /* */ read (fd, ); /* */ write

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 File I/O Jo, Heeseung 학습목표 오류처리함수동적메모리할당명령행인자 2 오류처리함수 [1] 오류메시지출력 : perror(3) #include void perror(const char *s); [ 예제 1-4] perror 함수사용하기 01 #include 02 #include 03

More information

Microsoft PowerPoint - chap1 [호환 모드]

Microsoft PowerPoint - chap1 [호환 모드] 고급시스템프로그래밍 제 1 장소개 창병모숙명여대컴퓨터과학과 1 강의목적 시스템프로그래밍 file, process, network programming Unix 시스템의체계적이해 고급시스템프로그래밍능력향상 2 동기 시스템프로그래밍 OS 지원을이용한프로그래밍 Unix 시스템호출사용 file, process, IPC, networking, 파일관리소프트웨어네트워크관련소프트웨어

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Error and Command Line Arguments Jo, Heeseung 학습목표 오류처리함수동적메모리할당명령행인자 2 오류처리함수 [1] 오류메시지출력 : perror(3) #include void perror(const char *s); [ 예제 1-4] perror 함수사용하기 01 #include 02

More information

슬라이드 1

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

More information

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력 학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력을예측하시오. $ cd /usr $ ls..? $ ls.? 2. 다음그림은어떤프로세스가다음코드를수행했다는가정에서도시되었다.

More information

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

int main(void) int a; int b; a=3; b=a+5; printf(a : %d \n, a); printf(b : %d \n, b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf( a : %x \ ? 1 int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \n", &a); printf(" b : %x \n", &b); * : 12ff60,

More information

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

Microsoft PowerPoint - chap11.ppt [호환 모드] 2010-1 학기프로그래밍입문 (1) 11 장입출력과운영체제 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr k 0 특징 printf() - 임의의개수의인자출력 - 간단한변환명세나형식을사용한출력제어 A Book on C, 4ed. 11-1 printf() printf(control_string, other_argument) -

More information

11장 포인터

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

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

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

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

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

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

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

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

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 05 make 광운대학교로봇 SW 교육원 최상훈 학습목표 2 Makefile 을작성핛수있다. make 3 make 프로젝트관리유틸리티 컴파일시갂단축 파일의종속구조를빠르게파악핛수있음 기술파일 (Makefile) 에기술된대로컴파일명령또는셸 (shell) 명령을순차적으로수행 make 를사용하지않을경우 $ gcc c main.c $ gcc c test_a.c

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

歯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

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

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

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D> 학습목표 통신프로그램이무엇인지이해한다. 을이용한 IPC 기법을이해한다. 함수를사용해프로그램을작성할수있다. IT CookBook, 유닉스시스템프로그래밍 2/20 목차 의개념 함수 해제함수 의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 의개념 파일을프로세스의메모리에매핑 프로세스에전달할데이터를저장한파일을직접프로세스의가상주소공간으로매핑 read, write

More information

http://cafedaumnet/pway Chapter 1 Chapter 2 21 printf("this is my first program\n"); printf("\n"); printf("-------------------------\n"); printf("this is my second program\n"); printf("-------------------------\n");

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 종합과제 과제내용 구조체를이용하여교과목이름과코드를파일로부터입력받아관리 구조체를이용하여학생들의이름, 학번과이수한교과목의코드와점수를파일로부터입력 학생개인별총점, 평균계산 교과목별이수학생수, 총점및평균을계산 결과를파일에저장하는프로그램을작성 2 Makefile OBJS = score_main.o score_input.o score_calc.o score_print.o

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 메모리매핑 IT CookBook, 유닉스시스템프로그래밍 학습목표 통신프로그램이무엇인지이해한다. 메모리매핑을이용한 IPC 기법을이해한다. 메모리매핑함수를사용해프로그램을작성할수있다. 2/20 목차 메모리매핑의개념 메모리매핑함수 메모리매핑해제함수 메모리매핑의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 3/20 메모리매핑의개념 메모리매핑 파일을프로세스의메모리에매핑

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 프로그래밍 언어 입문 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

이번장에서학습할내용 동적메모리란? 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 사용자로부터받은두개의숫자 x, y 중에서큰수를찾는알고리즘을의사코드로작성하시오. Step 1: Input x, y Step 2: if (x > y) then MAX

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

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (t

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (t 학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (taesoo) 가터미널에서다음 ls 명령입력시화면출력을예측하시오. $ ls /usr/.. $

More information

PowerPoint 프레젠테이션

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

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

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

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

Standard C Library.hwp

Standard C Library.hwp Standard C I/O 이함수들은 C++ stream-based IO classes 를지원한다. #include clearerr void clearerr( FILE *stream ); FILE 포인터객체 stream의 EOF 표시자와오류표시자를모두재설정 (Reset) 한다. void fopen FILE *fopen(const char *fname,

More information

Microsoft PowerPoint - Ch12.파일.pptx

Microsoft PowerPoint - Ch12.파일.pptx 파일의기본개념과특징을이해한다. 파일처리과정을이해한다. 형식을지정한파일입출력 fscanf/fprintf를배운다. 문자단위입출력 fgetc/fputc를배운다. 문자열단위입출력 fgets/fputs를배운다. 이진파일입출력 fread/fwrite를배운다. 임의접근을통한파일입출력을위한 fseek, rewind, ftell을배운다. 12.0 개요 p.592 표준입출력과파일입출력

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

11장 포인터

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

More information

<4D F736F F F696E74202D20C1A63136C0E520C6C4C0CFC0D4C3E2B7C2>

<4D F736F F F696E74202D20C1A63136C0E520C6C4C0CFC0D4C3E2B7C2> 쉽게풀어쓴 C 언어 Express 제 16 장파일입출력 이번장에서학습할내용 스트립의개념 표준입출력 파일입출력 입출력관련함수 입출력에관련된개념들과함수들에대하여학습한다. 스트림의개념 스트림 (stream): 입력과출력을바이트 (byte) 들의흐름으로생각하는것 스트림과버퍼 스트림에는기본적으로버퍼가포함되어있다. 표준입출력스트림 기본적인스트림들은프로그래머가생성하지않아도자동으로생성된다.

More information

untitled

untitled while do-while for break continue while( ) ; #include 0 i int main(void) int meter; int i = 0; while(i < 3) meter = i * 1609; printf("%d %d \n", i, meter); i++; return 0; i i< 3 () 0 (1)

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

Microsoft PowerPoint - C프로그래밍-chap16.ppt

Microsoft PowerPoint - C프로그래밍-chap16.ppt Chapter 16 유도자료형 struct, union, enum 한국항공대학교항공우주기계공학부 1 구조체 (struct) 구조체의필요성 책에대한정보를살펴보면매우다양 책정보제목, 저자, 출판사, 페이지수, 가격, ISBN 등 struct 서로다른자료형의변수들을묶어서만든하나의새로운자료형을구조체 (struct) 구조체는연관된멤버로구성되는통합자료형으로대표적인유도자료형

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

Microsoft PowerPoint - chap12 [호환 모드]

Microsoft PowerPoint - chap12 [호환 모드] 제 12 장고급입출력 Nov 2007 숙대창병모 1 Contents 1. Nonblocking I/O 2. Record Locking 3. Memory Mapped I/O Nov 2007 숙대창병모 2 12.1 Nonblocking I/O Nov 2007 숙대창병모 3 Nonblocking I/O Blocking I/O I/O 작업완료를기다리며영원히리턴안할수있다

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

슬라이드 1

슬라이드 1 10 장입출력함수 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 2017-1 st 프로그래밍입문 (1) 2 printf() 특징 임의의개수의인자출력 간단한변환명세나형식을사용한출력제어 3 printf() printf(control_string, other_argument) 예 printf("she

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 10 장문자와문자열 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 문자와문자열처리방법에대하여살펴볼것이다. 문자표현방법 컴퓨터에서는각각의문자에숫자코드를붙여서표시한다. 아스키코드 (ASCII code): 표준적인 8비트문자코드 0에서 127까지의숫자를이용하여문자표현

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

표준입출력스트림 기본적인스트림들은프로그래머가생성하지않아도자동으로생성된다. 이름스트림연결장치 stdin 표준입력스트림키보드 stdout 표준출력스트림모니터의화면 stderr 표준오류스트림모니터의화면 입출력함수의분류 사용하는스트림에따른분류 표준입출력스트림을사용하여입출력을하

표준입출력스트림 기본적인스트림들은프로그래머가생성하지않아도자동으로생성된다. 이름스트림연결장치 stdin 표준입력스트림키보드 stdout 표준출력스트림모니터의화면 stderr 표준오류스트림모니터의화면 입출력함수의분류 사용하는스트림에따른분류 표준입출력스트림을사용하여입출력을하 쉽게풀어쓴 C 언어 Express 이번장에서학습할내용 제 16 장파일입출력 스트립의개념 표준입출력 파일입출력 입출력관련함수 입출력에관련된개념들과함수들에대하여학습한다. 스트림의개념 스트림 (stream): 입력과출력을바이트 (byte) 들의흐름으로생각하는것 스트림과버퍼 스트림에는기본적으로버퍼가포함되어있다. 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

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 비트연산자 1 1 비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 진수법! 2, 10, 16, 8! 2 : 0~1 ( )! 10 : 0~9 ( )! 16 : 0~9, 9 a, b,

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 인터넷프로토콜 5 장 데이터송수신 (3) 1 파일전송메시지구성예제 ( 고정크기메시지 ) 전송방식 : 고정크기 ( 바이너리전송 ) 필요한전송정보 파일이름 ( 최대 255 자 => 255byte 의메모리공간필요 ) 파일크기 (4byte 의경우최대 4GB 크기의파일처리가능 ) 파일내용 ( 가변길이, 0~4GB 크기 ) 메시지구성 FileName (255bytes)

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 10 장문자와문자열 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 문자와문자열처리방법에대하여살펴볼것이다. 문자표현방법 컴퓨터에서는각각의문자에숫자코드를붙여서표시한다. 아스키코드 (ASCII code): 표준적인 8비트문자코드 0에서 127까지의숫자를이용하여문자표현

More information