Computer programming in c chapter 7
Download
1 / 8

Computer Programming in C Chapter 7 - PowerPoint PPT Presentation


  • 121 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Computer Programming in C Chapter 7' - brent


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Computer programming in c chapter 7

Computer Programming in C Chapter 7

2013년 가을학기

부산대학교

정보컴퓨터공학부


7 input output and built in functions
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


1 i o
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


2 formatted i o
2. Formatted I/O

  • Formatted Input, Output: scanf, printf

Computer Programming Chapter 7


3 file access
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


4 various argument list
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


5 low level i o
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


6 memory managment
6. Memory Managment

  • malloc(size), calloc(number, size)

  • Dynamic Allocation vs. Static Allocation

Computer Programming Chapter 7