1 / 8

Computer Programming in C Chapter 7

Computer Programming in C Chapter 7. 2013 년 가을학기 부산대학교 정보컴퓨터공학부. 7 장 . Input/Output and Built-in Functions. 목차 Standard I/O Formatted I/O File Access Variable Length Argument List Low Level I/O Memory Management . 1. I/O 의 기본 개념 . Standard I/O Standard Input: Input from Keyboard

brent
Télécharger la présentation

Computer Programming in C Chapter 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Programming in C Chapter 7 2013년 가을학기 부산대학교 정보컴퓨터공학부

  2. 7장. Input/Output and Built-in Functions • 목차 • Standard I/O • Formatted I/O • File Access • Variable Length Argument List • Low Level I/O • Memory Management Computer Programming Chapter 7

  3. 1. I/O의 기본 개념 • Standard I/O • Standard Input: Input from Keyboard • Standard Output: Output to Screen • #include <stdio.h> • Example while((c=getchar()) != EOF) putchar(c); printf(“No Error\n”); scanf(“%d %d %s”, &year, &number, name); Computer Programming Chapter 7

  4. 2. Formatted I/O • Formatted Input, Output: scanf, printf Computer Programming Chapter 7

  5. 3. File Access • File Access • Sequential File vs. Random Access File • Some functions for Random Access File • Type: FILE (e.g. FILE *fp) • Functions • fopen, fclose • fgetc, fputc, fprintf, fscanf, fgets, fputs… • fseek: int fseek(fp, offset, origin) • SEEK_SET, SEEK_CUR, SEEK_END • ftell(fp) • rewind(fp) Computer Programming Chapter 7

  6. 4. Various Argument List • Number of Arguments: Not Fixed • Example: printf, scanf void minprintf(char *fmt,...) { va_list ap: int ival; double dval; va_start(ap,fmt); /* set ap to the first argument */ ival=va_arg(ap, int); /* fetch next integer argument */ dval=va_arg(ap, double); /* fetch next double argument */ va_end(ap); } Computer Programming Chapter 7

  7. 5. Low Level I/O • Low Level I/O • More efficient I/O • Type • int fd; file descriptor maintained by OS • fd=open(fileName,O_RDWR, 0);close(fd) • nbytes=read(fd, buffer, length); • nbytes=write(fd, buffer, length); • lseek: same as fseek except parameters lseek(fd, offset, origin) Computer Programming Chapter 7

  8. 6. Memory Managment • malloc(size), calloc(number, size) • Dynamic Allocation vs. Static Allocation Computer Programming Chapter 7

More Related