使用C语言删除文本文档中的一行数据

来源:互联网 发布:网络监控系统设计说明 编辑:程序博客网 时间:2024/06/04 20:11

1.问题:使用C语言删除文本文档中的一行数据

解决:test.txt 是要被删除一行数据的文本

#include<iostream>#include<fostream>using namespace std;void Delete() {    int i=0;    ifstream intf("test.txt");    ofstream out("tmp.txt");    string str1;    while( intf >> str1 )    {        if ( i == 0 )        {            i=1;            continue;        }        out << str1 << endl ;    }    out.close() ;    intf.close() ;    ifstream intff("tmp.txt");    ofstream outt("test.txt");        while( intff >> str1 )    {        outt << str1 << endl ;    }    intff.close();    outt.close() ;}
0 0
原创粉丝点击