把数据连续的输入到一个文件夹中
2015-12-10 16:15
381 查看
#include <fstream>
#include <string>
#include <iostream>
//using namespace std;
//
//void Createflile();
//void Readflie();
//void main()
//{
/*int cnt = 0;
string str;
ifstream fin("C:\\ds\\log.txt", ios::in);
if (!fin){
printf("The file is not exist!");
}
while (getline(fin, str))
{
cnt++;
cout << str << endl;*/
#include<iostream>
#include<vector>
using namespace std;
int main()
{
char* path = "C:\\ds\\log.txt";
fstream _file;
_file.open("C:\\ds\\log.txt", ios::in);
if (_file)
{
std::cout << "已经创建了"<< std::endl;
//_file >> "sda" >> endl;
ofstream fout(path, ios::app);
for (size_t i = 0; i < 3; i++)
{
fout << "asdsad" << endl;
}
}
else
{
ofstream fout(path);
for (size_t i = 0; i < 3; i++)
{
fout << "asdsad" << endl;
}
fout.close();
}
#include <string>
#include <iostream>
//using namespace std;
//
//void Createflile();
//void Readflie();
//void main()
//{
/*int cnt = 0;
string str;
ifstream fin("C:\\ds\\log.txt", ios::in);
if (!fin){
printf("The file is not exist!");
}
while (getline(fin, str))
{
cnt++;
cout << str << endl;*/
#include<iostream>
#include<vector>
using namespace std;
int main()
{
char* path = "C:\\ds\\log.txt";
fstream _file;
_file.open("C:\\ds\\log.txt", ios::in);
if (_file)
{
std::cout << "已经创建了"<< std::endl;
//_file >> "sda" >> endl;
ofstream fout(path, ios::app);
for (size_t i = 0; i < 3; i++)
{
fout << "asdsad" << endl;
}
}
else
{
ofstream fout(path);
for (size_t i = 0; i < 3; i++)
{
fout << "asdsad" << endl;
}
fout.close();
}
相关文章推荐
- php输入流php://input使用浅析
- PHP输入流php://input介绍
- Android中文件读写(输入流和输出流)操作小结
- Java输入流Scanner/BufferedReader使用方法示例
- 详细解读Java编程中面向字符的输入流
- IO流
- java使用两个scanner,关闭输入流
- 关于Java Socket和创建输入输出流的几点注意
- apache FileUtils 和 IOUtils 工具类 改写普通文件读写方式 提高效率
- Java IO(三) 之 FileInputStream
- Java IO(二) 之 InputStream
- 深入理解java字节流与字符流
- JAVA中的IO 流们
- JAVA_IO简记
- IO/输入输出
- 算法习题38:百度面试题(天平,大量输入流,URL去重)
- Java IO流《总览》
- IO编程——文件复制操作
- cin>>和getline混用需谨慎
- JSP 中的文件操作