[問題] Text Input/Output 的幾個問題
目前我學到這裡~
關於開讀檔的方法, 有r, w, a三種mode
(其他還沒在書上看到)
昨天再寫書後面的習題遇到幾個問題:
1. 如果我要對一個file多次使用fgetc時
是不是用完一次fgetc就必須fclose再fopen
不然會造成第二次讀的時候就直接讀到EOF?
昨天試的時候是這樣, 不過不知道對不對
因為我在想要用很多次fgetc, 一直fopen, fclose
很麻煩
2. Q1: write a function that deletes the last line of any file
Q2: write a program to delete the sixth line in a file
類似這樣的問題, 像問題2, 如果是copy 1~5 & 7~last到另一個file
然後再write回去, 這樣我會
但要是只能使用original file, 不能用其他file
就不知道要怎麼辦了...
3. 剩下的是我不知道題目的意思
我看得懂字面上的意思, 整個題意還是不懂
(1) Write a function that accepts a file of varying-length lines and
changes it to a formatted file with 60 characters in each line.
(2) Write a program to parse words onto separate lines; that is,
locate and write each word to its own line. Words are defined
as one or more characters seperated by whiltspace.
(3) Write a function that writes the multiples of "num" between
"lowLimit" and "highLimit" to a text file. Assume that
lowLimit < highLimit and that "num" is not equal to zero.
Then write a test driver to validate your function.
-----------
抱歉...我的問題有點多...
雖然原文寫的很詳細...不過也時候真的看不懂意思
請大家多多幫忙了^^
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.120.193.39
→
08/20 12:37, , 1F
08/20 12:37, 1F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章