文档详情

第九章 - 格式化输入输出.pdf

发布:2015-09-14约4.36万字共26页下载文档
文本预览下载声明
1 第九章 -格式化輸入輸出/ • 本章內容 – 了解輸入輸出串流 – 了解所有列印格式 – 了解所有輸入格式 © Copyright 1992–2004 by Deitel Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 9.2 Streams • Streams(串流 ) –輸入或輸出可看成由很多文字行組成 • 每行由0或多個字元組成 , 換行符號結尾 • ANSI C一行最少要有254個字元 – 通常可被重新導向(redirected) • Standard input – keyboard • Standard output – screen • Standard error – screen • More in Chapter 11 © Copyright 1992–2004 by Deitel Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 3 9.3格式化輸出使用printf • printf – 精確的格式化輸出 • 指定轉換方式: 旗號,欄位寬度 , 精確度, 等. –可做 • rounding, aligning columns, • right/left justification, • inserting literal characters, • exponential format, • hexadecimal format, • and fixed width and precision © Copyright 1992–2004 by Deitel Associates, Inc. and Pearson Education Inc. All Rights Reserved. 4 9.3格式化輸出使用printf • 格式 – printf(format-control-string, other-arguments ); – Format control string: •使用轉換識別字描述輸出方式 • 每個轉換識別字由%符號外加控制碼組成 – Other-arguments: •要輸出的資料項目 © Copyright 1992–2004 by Deitel Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2
显示全部
相似文档