摘要:
1. 文件和流的关系 C将每个文件简单地作为顺序字节流(如下图)。每个文件用文件结束符结束,或者在特定字节数的地方结束,这个特定的字节数可以存储在系统维护的管理数据结构中。当打开文件时,就建立了和文件的关系。 在开始执行程序的时候,将自动打开3个文件和相关的流:标准输入流、标准输出流和标准错误。... 阅读全文
摘要:
fseek库函数#include int fseek(FILE *stream, long int offset, int origin);返回:成功为0,出错为非0 对流stream相关的文件定位,随后的读写操作将从新位置开始。对于二进制文件,此位置被定位在由origin开始的offse... 阅读全文
摘要:
The standard library function calloc(n,size) returns a pointer to n objects of size size , with the storage initialized to zero. Write calloc , by cal... 阅读全文
摘要:
Write a function reverse(s) that reverses the character string s . Use it to write a program that reverses its input a line at a time. #include #defin... 阅读全文
摘要:
Write a program to remove all trailing blanks and tabs from each line of input, and to delete entirely blank lines. 其实做这道题目有两种思路: 1.后向模式:利用getline()先... 阅读全文
摘要:
Revise the main routine of the longest-line program so it will correctly print the length of arbitrarily long input lines, and as much as possible of ... 阅读全文
摘要:
Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orien... 阅读全文
摘要:
How would you test the word count program? What kinds of input are most likely to uncover bugs if there are any? 你会如何测试前面的字符统计程序呢?什么样的测试输入,最能揭示你程序中的bu... 阅读全文
摘要:
Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. 编写这样一个程序,实现将输入流复制到输出流,但是要将输入流中多个空格过... 阅读全文