UNIX 시스템 프로그래밍..도와주세요..

endless629의 이미지

A. implement simple "cat" command using library functions
프로그램의 명령어 줄에 파일 이름을 주면, 그 파일의 내용이 화면에 그대로 출력되는 프로그램을 작성하라.
Unix / Linux의 cat 명령, Windows의 type 명령이 하는 일과 동일한 작업을 하면 된다.
구현의 편의를 위해, option은 일체 구현하지 않고, 아래의 예제와 같이, 파일 이름들에 대해서만 처리해 주면 된다.
open( ), close( ), read( ) 등의 system call은 일체 사용하지 말고, fopen( ), fclose( ), fgets( ),
fputs( ) 등의 에서 제공하는 함수들만 사용하여야 한다. (즉, 사용한 함수들은 모두 manual section 3에서 찾을 수 있는 함수들이어야 한다.)
참고할 만한 것들: BUFSIZ in or , freopen( ).
작성한 프로그램은 컴파일 후에 다음과 같이 작동하여야 한다. (굵은 글씨는 사용자 입력, '$'는 prompt)

$ cat alpha.txt
This is the file, ALPHA.
$ cat bravo.txt
This is another file, BRAVO.
$ cat alpha.txt bravo.txt
This is the file, ALPHA.
This is another file, BRAVO.
$ cat < alpha.txt
This is the file, ALPHA.
$ cat alpha.txt charlie.txt bravo.txt
This is the file, ALPHA.
cat: cannot open charlie.txt
This is another file, BRAVO.
$ gcc -o unix02A unix02A.c
$ ./unix02A alpha.txt
This is the file, ALPHA.
$ ./unix02A bravo.txt
This is another file, BRAVO.
$ ./unix02A alpha.txt bravo.txt
This is the file, ALPHA.
This is another file, BRAVO.
$ ./unix02A < alpha.txt
This is the file, ALPHA.
$ ./unix02A alpha.txt charlie.txt bravo.txt
This is the file, ALPHA.
./unix02B: charlie.txt: No such file or directory
This is another file, BRAVO.
$

B. implement simple "cat" command using system call functions
위의 A번 문제를 그대로 풀되, open( ), read( ), close( ) 등의 system call 만을 사용하고,
의 함수들은 일체 사용하지 않도록 한다. (즉, 사용한 함수들은 모두 manual
section 2에서 찾을 수 있어야 한다.)

작성한 프로그램은 컴파일 후에 다음과 같이 작동하여야 한다. (굵은 글씨는 사용자 입력, '$'는 prompt)
아래 예는 cs.knu.ac.kr 기준이고, 다른 기계에서는 error message만은 약간 다른 형식으로
나올 수도 있다.

$ cat alpha.txt
This is the file, ALPHA.
$ cat bravo.txt
This is another file, BRAVO.
$ cat alpha.txt bravo.txt
This is the file, ALPHA.
This is another file, BRAVO.
$ cat < alpha.txt
This is the file, ALPHA.
$ cat alpha.txt charlie.txt bravo.txt
This is the file, ALPHA.
cat: cannot open charlie.txt
This is another file, BRAVO.
$ gcc -o unix02B unix02B.c
$ ./unix02B alpha.txt
This is the file, ALPHA.
$ ./unix02B bravo.txt
This is another file, BRAVO.
$ ./unix02B alpha.txt bravo.txt
This is the file, ALPHA.
This is another file, BRAVO.
$ ./unix02B < alpha.txt
This is the file, ALPHA.
$ ./unix02B alpha.txt charlie.txt bravo.txt
This is the file, ALPHA.
./unix02C: charlie.txt: No such file or directory
This is another file, BRAVO.
$

>>가르쳐 주시면 사례 하겠습니다..꾸벅

dorado2의 이미지

Heaven helps those who help themselves.

dragonkun의 이미지

어디까지 알아보시고 오셨나요? (용팔이 버젼..-_-)
--
Emerging the World!

Emerging the World!

yongdory의 이미지

제가 알려드릴까요? 네이트온좀

sheep의 이미지

숙제는 혼자서...

--------
From Buenos Aires, Argentina
No sere feliz pero tengo computadora.... jaja
닥치고 Ubuntu!!!!!
To Serve My Lord Jesus
blog: http://sehoonpark.com.ar (블로그 주소 바꼈습니다)

--------
From Buenos Aires, Argentina
No sere feliz pero tengo computadora.... jaja
닥치고 Ubuntu!!!!!
To Serve My Lord Jesus
blog: http://sehoonpark.com.ar
http://me2day.net/sheep

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.