HackingC++ Learning笔记 Chapter2-Input&Output
文章目录
个人笔记向+google机翻(机翻确实很多细节描述不清,看不懂记得参考原文)
原文参见:https://hackingcpp.com/cpp/be...
Input&Output
1.Command Line Arguments 命令行参数
- What &Why
How to Access in C++
int main (int const argc, char const* argv/*a pointer to a constant char*/) {- Argument Conversion
Conversion to std::string, int, …
auto word = string(argv[1]); int times = atoi(argv[2]);- String → Number Conversion Functions

2.File Input&Output 文件输入输出
- Write Text File
Read Text File
#include <fstream> std::ofstream os {"squares.txt"}; os << xxxxx ; std::ifstream is {"squares.tst"}; is >> xxxxx ;Open/Close Files
os.open("squares.txt"); os.close("squares.txt");- File Open Modes

3.Stream Input&Output 流输入输出
Example: Point Coordinate I/O
4.Recover From Input Error 从输入错误中恢复

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论