chap7.key

Size: px
Start display at page:

Download "chap7.key"

Transcription

1 1 7 C

2 2 7.1

3 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3

4 (system call). 4

5 C?... 5

6 C (text file), C. (binary file). 6

7 C 1. : fopen( ) 2. : 3. : fclose( ) 7

8 (fopen). FILE FILE. fopen() FILE *fopen(const char *filename, const char *mode); const char *filename: const char *mode: FILE *fp; fp = fopen( ~/sp/text.txt", "r"); if (fp == NULL) { printf(" \n"); } fp = fopen("outdata.txt", "w"); fp = fopen("outdata.txt", "a"); 8

9 fopen (): "r" (read) NULL "w" (write) "a" (append) "r+" NULL "w+" "a+" 9

10 FILE (file descriptor) C fopen( ) FILE (FILE *) FILE FILE #include <stdio.h> FILE, 10

11 FILE FILE : typedef struct { int cnt; unsigned char*base; unsigned char*ptr; // // // unsinged flag; int fd; } FILE; // FILE // ( _IOFBF, _IOLBF, _IONBUF, // _IOEOF, _IOERR _IOREAD, _IOWRT) // 11

12 / / I/O (stream) open stdin, stdout, stderr FILE* #include <stdio.h> stdin FILE stdout FILE stderr FILE 12

13 . int fclose(file *fp ); fp fopen 0, EOF( -1). fclose(fp); 13

14 7.2

15 getchar() fgetc(), getc() putchar() fputc(), putc() gets() fgets() puts() fputs() scanf() fscanf() printf() fprintf()

16 fgetc() fputc(). int fgetc(file *fp); getc fp. EOF(-1). int fputc(int c, FILE *fp); putc EOF(-1) 16

17 cat.c #include <stdio.h> /* */ int main(int argc, char *argv[]) { FILE *fp; int c; if (argc < 2) fp = stdin; // else fp = fopen(argv[1],"r"); // c = getc(fp); // while (c!= EOF) { // putc(c, stdout); // c = getc(fp); // } fclose(fp); return 0; } 17

18 copy.c ( ) #include <stdio.h> /* */ int main(int argc, char *argv[]) { char c; FILE *fp1, *fp2; if (argc!=3) { fprintf(stderr, " : %s 1 2\n", argv[0]); return 1; } 18

19 copy.c fp1 = fopen(argv[1], "r"); if (fp1 == NULL) { fprintf(stderr, " %s \n", argv[1]); return 2; } fp2 = fopen(argv[2], "w"); while ((c = fgetc(fp1))!= EOF) fputc(c, fp2); } fclose(fp1); fclose(fp2); return 0; 19

20 int feof(file *fp) fp 0 0. int ungetc(int c, FILE *p) c. 1. int fflush(file *fp) fp.. 20

21 fgets() fputs(). char* fgets(char *s, int n, FILE *fp); s s ('\n') EOF n-1 NULL. NULL. int fputs(const char *s, FILE *fp); s fp EOF 21

22 line.c 1 #include <stdio.h> 2 #define MAXLINE /*. */ 5 int main(int argc, char *argv[]) 6 { 7 FILE *fp; 8 int line = 0; 9 char buffer[maxline]; if (argc!= 2) { 12 fprintf(stderr, " :line \n"); 13 exit(1); 14 } 22

23 line.c if ( (fp = fopen(argv[1],"r")) == NULL) 17 { 18 fprintf(stderr, " 23 line++; 19 exit(2); 20 } while (fgets(buffer, MAXLINE, fp)!= NULL) { // 23 line++; 24 printf("%3d %s", line, buffer); 25 } 26 exit(0); 27 } 23

24 fprintf() printf(). fscanf() scanf(). int fprintf(file *fp, const char *format,...); fprintf fp FILE printf int fscanf(file *fp, const char *format,...); fscanf fp FILE scanf 24

25 fprint.c #include <stdio.h> #include "student.h" /*. */ int main(int argc, char* argv[]) { struct student rec; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); return 1; } fp = fopen(argv[1], "w"); printf("%-9s %-7s %-4s\n", " ", " ", " "); while (scanf("%d %s %d", &rec.id, rec.name, &rec.score)==3) fprintf(fp, "%d %s %d ", rec.id, rec.name, rec.score); fclose(fp); return 0; } 25

26 fscan.c #include <stdio.h> #include "student.h" /*. */ int main(int argc, char* argv[]) { struct student rec; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); return 1; } fp = fopen(argv[1], "r"); printf("%-9s %-7s %-4s\n", " ", " ", " "); while (fscanf(fp,"%d %s %d", &rec.id, rec.name, &rec.score)==3) printf("%10d %6s %6d\n", rec.id, rec.name, rec.score); fclose(fp); return 0; } 26

27 7.3

28 fopen(): "rb" (read) NULL "wb" (write) "ab" (append) "rb+" NULL "wb+" "ab+" 28

29 fread() fwrite() int fread(void *buf, int size, int n, FILE *fp); fp size ( ) n buf int fwrite(const void *buf, int size, int n, FILE *fp); fp buf size ( ) n 29

30 fwrite() 30

31 : rec struct student rec; FILE *fp = fopen( stfile", "wb"); fwrite(&rec, sizeof(rec), 1, fp); 31

32 stcreate1. c #include <stdio.h> #include "student.h" int main(int argc, char* argv[]) { struct student rec; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n",argv[0]); exit(1); } student.h struct student { int id; char name[20]; short score; }; fp = fopen(argv[1], "wb"); printf("%-9s %-7s %-4s\n", " ", " ", " "); while (scanf("%d %s %d", &rec.id, rec.name, &rec.score) == 3) fwrite(&rec, sizeof(rec), 1, fp); } fclose(fp); exit(0); 32

33 fread() 33

34 stprint.c #include <stdio.h> #include "student.h" /*. */ int main(int argc, char* argv[]) { struct student rec; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); return 1; } if ((fp = fopen(argv[1], "rb")) == NULL ) { fprintf(stderr, " \n"); return 2; } 34

35 stprint.c printf(" \n"); printf("%10s %6s %6s\n", " ", " ", " "); printf(" \n"); while (fread(&rec, sizeof(rec), 1, fp) > 0) if (rec.id!= 0) printf("%10d %6s %6d\n", rec.id, rec.name, rec.score); } printf(" \n"); fclose(fp); return 0; 35

36 7.4 36

37 (current file position) (file position pointer). 37

38 fseek(file *fp, long offset, int mode) rewind(file *fp). ftell(file *fp) 38

39 fseek() fseek(file *fp, long offset, int mode) FILE fp (mode) (offset). SEEK_SET 0 SEEK_CUR 1 SEEK_END 2 39

40 fseek() fseek(fd, 0L, SEEK_SET); (rewind) fseek(fd, 100L, SEEK_SET); 100 fseek(fd, 0L, SEEK_END); (append) fseek(fd, n * sizeof(record), SEEK_SET); n+1 fseek(fd, sizeof(record), SEEK_CUR); fseek(fd, -sizeof(record), SEEK_CUR); fseek(fd, sizeof(record), SEEK_END); 40

41 : fwrite(&record1, sizeof(record), 1, fp); fwrite(&record2, sizeof(record), 1, fp); fseek(fd, sizeof(record), SEEK_END); fwrite(&record3, sizeof(record), 1, fp); #1 #2 #3 41

42 stcreate2.c #include <stdio.h> #include "student.h" #define START_ID /*. */ int main(int argc, char* argv[]) { struct student rec; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); exit(1); } 42

43 stcreate2.c } fp = fopen(argv[1], "wb"); printf("%7s %6s %4s\n", " ", " ", " "); while (scanf("%d %s %d", &rec.id, rec.name, &rec.score) == 3) { fseek(fp, (rec.id START_ID)* sizeof(rec), SEEK_SET); fwrite(&rec, sizeof(rec), 1, fp); } fclose(fp); exit(0); 43

44 stquery.c #include <stdio.h> #include "student.h" int main(int argc, char *argv[]) { struct student rec; char c; int id; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); exit(1); } if ((fp = fopen(argv[1], "rb")) == NULL ) { fprintf(stderr, " \n"); exit(2); } 44

45 stquery.c do { printf(" : "); if (scanf("%d", &id) == 1) { fseek(fp, (id - START_ID) *sizeof(rec), SEEK_SET); if ((fread(&rec, sizeof(rec), 1, fp) > 0) && (rec.id!= 0)) printf(" : %8d : %4s : %4d\n", rec.id, rec.name, rec.score); else printf(" %d \n", id); } else printf(" "); printf("?(y/n)"); scanf(" %c", &c); } while (c == 'Y'); } fclose(fp); exit(0); 45

46 (1) (2) (3). 46

47 stupdate.c #include <stdio.h> #include "student.h" /*. */ int main(int argc, char *argv[]) { struct student rec; int id; char c; FILE *fp; if (argc!= 2) { fprintf(stderr, " : %s \n", argv[0]); exit(1); } if ((fp = fopen(argv[1], "rb+")) == NULL) { fprintf(stderr, " \n"); exit(2); } 47

48 stupdate.c do { printf(" : "); if (scanf("%d", &id) == 1) { fseek(fp, (id - START_ID) * sizeof(rec), SEEK_SET); if ((fread(&rec, sizeof(rec), 1, fp) > 0)&&(rec.id!= 0)) { printf(" : %8d : %4s : %4d\n", rec.id, rec.name, rec.score); printf(" : "); scanf("%d", &rec.score); fseek(fp, -sizeof(rec), SEEK_CUR); fwrite(&rec, sizeof(rec), 1, fp); } else printf(" %d \n", id); } else printf(" \n"); printf("?(y/n)"); scanf(" %c",&c); } while (c == 'Y'); fclose(fp); exit(0); } 48

49 49 7.5

50 C C I/O read (), write () I/O C (fully buffered) (line buffered) (unbuffered) 50

51 C I/O (newline) I/O (stdin, stdout). (stderr) 51

52 buffer.c #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *fp; if (!strcmp(argv[1], "stdin")) { fp = stdin; printf(" :"); if (getchar() == EOF) perror("getchar"); } else if (!strcmp(argv[1], "stdout")) fp = stdout; else if (!strcmp(argv[1], "stderr")) fp = stderr; else if ((fp = fopen(argv[1], "r")) == NULL) { perror("fopen"); exit(1); } else if (getc(fp) == EOF) perror("getc"); 52

53 buffer.c printf(" = %s, ", argv[1]); if (fp->_flags & _IO_UNBUFFERED) printf(" "); else if (fp->_flags & _IO_LINE_BUF) printf(" "); else printf(" "); } printf(", = %d\n", fp->_io_buf_end - fp->_io_buf_base); exit(0); 53

54 setbuf()/setvbuf() #include <stdio.h> void setbuf (FILE *fp, char *buf ); int setvbuf (FILE *fp, char *buf, int mode, size_t size );, 54

55 setbuf() void setbuf (FILE *fp, char *buf ); on/off. buf NULL buf BUFSIZ / 55

56 setvbuf() int setvbuf (FILE *fp, char *buf, int mode, size_t size ); : 0, nonzero mode _IOFBF : _IOLBF : _IONBF : 56

57 setvbuf() mode == _IONBF buf size mode == _IOLBF or _IOFBF buf NULL buf size NULL stat st_blksize (disk files) st_blksize BUFSIZ (pipes) 57

58 :setbuf #include <stdio.h> main() { printf(", "); sleep(1); printf("!"); sleep(1); printf(" \n"); sleep(1); setbuf(stdout, NULL); printf(", "); sleep(1); printf(" "); sleep(1); printf(" ^^"); sleep(1); printf(" \n"); sleep(1); } 58

59 :setvbuf #include <stdio.h> int main( void ) { char buf[1024]; FILE *fp1, *fp2; fp1 = fopen("data1", "a"); fp2 = fopen("data2", "w"); if( setvbuf(fp1, buf, _IOFBF, sizeof( buf ) )!= 0 ) printf(" : \n" ); else printf(" : 1024 \n" ); } if( setvbuf(fp2, NULL, _IONBF, 0 )!= 0 ) printf(" : \n" ); else printf(" : \n" ); 59

60 fflush() #include <stdio.h> int fflush (FILE *fp); fp write() : 0, EOF (-1) fp NULL, 60

61 . fopen() FILE. FILE. fgetc() fputc(). fgets() fputs(). fread() fwrite().. fseek(). 61

제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

제7장 C 표준 파일 입출력

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

More information

제7장 C 표준 파일 입출력

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

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

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

PowerPoint 프레젠테이션

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

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

PowerPoint 프레젠테이션

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

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 Template

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

More information

C Programming

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

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

슬라이드 1

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

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

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054>

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

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

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

11장 포인터

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

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö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

제1장 Unix란 무엇인가?

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

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

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

BMP 파일 처리

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

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

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

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

2009년 상반기 사업계획

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

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

<4D F736F F F696E74202D FC6C4C0CF20C0D4C3E2B7C2205BC8A3C8AF20B8F0B5E55D>

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

More information

슬라이드 1

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

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 - chap1 [호환 모드]

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

More information

<4D F736F F F696E74202D20C1A63136C0E520C6C4C0CFC0D4C3E2B7C2>

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

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

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

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

More information

제1장 Unix란 무엇인가?

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

More information

Microsoft PowerPoint - 11_C_Language_C_Standard_Library

Microsoft PowerPoint - 11_C_Language_C_Standard_Library C Language C 표준라이브러리 Doo-ok Seo clickseo@gmail.com http:// 목 차 표준입출력함수 : 문자열조작함수 : 문자관련함수 : 유틸리티함수 : 시간및날짜관련함수 : 수학관련함수 : 2 표준라이브러리함수 표준라이브러리

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

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

<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

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 - C프로그래밍-chap16.ppt

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

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

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

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

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 - C_Programming_Basics.ppt [호환 모드]

Microsoft PowerPoint - C_Programming_Basics.ppt [호환 모드] C 언어 기본사항 프로그램의 기본 틀 main 함수 프로그램의 시작점이자 종료지점 printf 함수를이용한문자열출력 문자열 프로그램상에서는큰따옴표로묶어서표현한다. printf 함수의기능 큰따옴표로묶여서표현되는문자열의출력 printf 함수의호출을위해필요한것 #include 의삽입 '\n' 은개행의의미를 #include 지니는

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

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

PowerPoint 프레젠테이션

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

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

학번 : 이름 : 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

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

슬라이드 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

고급 프로그래밍 설계

고급 프로그래밍 설계 UNIT 09 표준 I/O 라이브러리 광운대학교로봇 SW 교육원 최상훈 시스템호출 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

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

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

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

More information

데이타전송

데이타전송 Network Programming Autumn 2009 C Programming Related with Data Transfer and PDU Encapsulations Contents Dynamic Memory Allocation (Review!) Bit Stream I/O Bit Operations in C Conversion of Little and

More information

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

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

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C4C656D70656C2D5A69762E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C4C656D70656C2D5A69762E637070> /* */ /* LZWIN.C : Lempel-Ziv compression using Sliding Window */ /* */ #include "stdafx.h" #include "Lempel-Ziv.h" 1 /* 큐를초기화 */ void LZ::init_queue(void) front = rear = 0; /* 큐가꽉찼으면 1 을되돌림 */ int LZ::queue_full(void)

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

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

<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

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 표준입출력 printf() (1) 특징 임의의개수의인자출력 간단한변환명세나형식을사용한출력제어 형식 printf(control_string, other_argument) 예 printf("she sells %d %s for $%f", 99, "sea shells", 3.77); control_string: "she sells %d %s for $%f"

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

歯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

연습문제만-수정

연습문제만-수정 10 Call by Value Call by Reference Call by Result Call by Name C call by value void int X int hap(int x, int y, int z, int w); printf("%d\n", hap(3, 4, 5, 6)); int hap(int x, int y, int z, int w) return

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2>

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2> 문자열처리라이브러리 함수 설명 strlen(s) 문자열 s의길이를구한다. strcpy(s1, s2) s2를 s1에복사한다. strcat(s1, s2) s2를 s1의끝에붙여넣는다. strcmp(s1, s2) s1과 s2를비교한다. strncpy(s1, s2, n) s2의최대n개의문자를 s1에복사한다. strncat(s1, s2, n) s2의최대n개의문자를 s1의끝에붙여넣는다.

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

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

학번 : 이름 : 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 12 표준입출력과파일입출력... 1. 표준입출력함수 2. 파일입출력함수 1. 표준입출력함수 표준입출력함수 표준입력 (stdin, Standard Input) : 키보드입력 표준출력 (stdout, StandardOutput) : 모니터출력 1. 표준입출력함수 서식화된입출력함수 printf(), scanf() 서식의위치에올수있는것들 [ 기본 11-1]

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

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

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

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

<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

11장 포인터

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

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

untitled

untitled 자료형 기본자료형 : char, int, float, double 등 파생자료형 : 배열, 열거형, 구조체, 공용체 vs struct 구조체 _ 태그 _ 이름 자료형멤버 _ 이름 ; 자료형멤버 _ 이름 ;... ; struct student int number; // char name[10]; // double height; // ; // x값과 y값으로이루어지는화면의좌표

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

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

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

3. 다음그림은프로세스의 file table 과 v-node 테이블의연결관계예제이다. 위그림을참고하여두개의서로다른프로세스가같은파일을 open 명령을사용하여열었을때의연결관계를도시하시오. 4. 메모리영역은 low-address 부터 high-adress 까지순서대로나열했을

3. 다음그림은프로세스의 file table 과 v-node 테이블의연결관계예제이다. 위그림을참고하여두개의서로다른프로세스가같은파일을 open 명령을사용하여열었을때의연결관계를도시하시오. 4. 메모리영역은 low-address 부터 high-adress 까지순서대로나열했을 학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (taesoo) 가터미널에서다음 ls 명령입력시화면출력을예측하시오. $ ls /usr/. $ ls

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

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

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

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

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

vi 사용법

vi 사용법 네트워크프로그래밍 6 장과제샘플코드 - 1:1 채팅 (udp 버전 ) 과제 서버에서먼저 bind 하고그포트를다른사람에게알려줄것 클라이언트에서알려준포트로접속 서로간에키보드입력을받아상대방에게메시지전송 2 Makefile 1 SRC_DIR =../../common 2 COM_OBJS = $(SRC_DIR)/addressUtility.o $(SRC_DIR)/dieWithMessage.o

More information