您好,欢迎来到刀刀网。
搜索
您的当前位置:首页C++txt文件读取和写入

C++txt文件读取和写入

来源:刀刀网

//写

#include<iostream>

#include<fstream>
using namespace std;

int main()
{
    string id,name;
    double grade;
    ofstream write;
    write.open("E:\\practice\\程序设计B\\ttt.txt",ios::in);

    if(!write)
    {
        cout << "can not" << endl;

        abort();
    }

    write << "学生管理" << endl;
    cout << "输入id,name,grade" << endl;
    while(cin >> id >> name >> grade)
    {
        write << id << ' ' << name << ' ' << grade << endl;
    }

    write.close();
}

//读

#include<iostream>

#include<fstream>
using namespace std;

int main()
{
    char s[100];
    string id,name;
    dou

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- gamedaodao.com 版权所有 湘ICP备2022005869号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务