一、文件输入输出

C/C++

输入:

freopen("in.cpp", "r", stdin);
fclose(stdin);

输出:

freopen("in.cpp", "r", stdout);
fclose(stdout);

C++

输入:

ifstream cin("in.cpp");

cin.close();

输出:

ofstream cout("out.cpp");

cout.close();

二、istringstream ostringstream 和 stringstream.

常用函数:

string str, s;

stringstream str;

stringstring str(s);

str.clear();

str.str(s);

Eg:

#include <sstream>
#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std; string str, name, pnum;
string outstr; int main() {
ifstream cin("in.cpp");
ofstream cout("out.cpp");
stringstream imess;
stringstream omess;
while (getline(cin, str)){
imess.clear();
omess.str("");
imess.str(str); imess >> name;
omess << name << ":"; while(imess >> pnum) {
omess << " " << pnum;
}
cout << omess.str() << endl;
}
cin.close();
cout.close();
return 0;
}

最新文章

  1. 作业八:团队项目——Alpha阶段项目总结
  2. Git标签和别名管理
  3. Spring Framework------&gt;version4.3.5.RELAESE-----&gt;Reference Documentation学习心得-----&gt;使用spring framework的IoC容器功能-----&gt;方法一:使用XML文件定义beans之间的依赖注入关系
  4. 智能指针 ADO数据库连接
  5. PHP--正则表达式和样式匹配--小记
  6. cat主要有三大功能
  7. word中几个好用的宏代码(立方米上标、关闭样式自动更新、删除无效样式、表格加粗边框、宋体引号)
  8. SharedPreferences基础
  9. 猎豹移动(金山网络)2015校园招聘(c++project师)
  10. Codeforces 432E Square Tiling(结构体+贪婪)
  11. CoreJavaE10V1P3.5 第3章 Java的基本编程结构-3.5 操作符
  12. php--php调java接口验签
  13. MySQL 实现调用外部程序和系统命令
  14. http 状态表
  15. 配置非安装版tomcat服务
  16. Junit的Assert用法
  17. Swift可向上滑移出界面的欢迎页简单封装
  18. appium 3-31626 toast识别
  19. sql server 存储过程解密
  20. Dubbo---初识

热门文章

  1. 工程源码github地址
  2. Java敏捷数据库迁移框架&mdash;&mdash;Flyway
  3. mysql概要(五)union
  4. python 标准库
  5. 关于Socket的经验小结
  6. jquery mobile 学习总结
  7. js object(对象)
  8. a++累加
  9. Android GestureDetector方法详解
  10. 使用Python获取Linux系统的各种信息