⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新文件1.cpp

📁 讀取檔案文字並輸入成陣列之後
💻 CPP
字号:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
    ifstream f1;
    f1.open("phone.lst");
    char ch;
    int count = 0;
    string line;

    ofstream f2("phAry.txt");

    while(!f1.eof()){
                     f1.get(ch);
                     if(ch != '\n') line += ch;
                     else{
                           if(line != ""){
                           f2 << "phAry["<< count << "]=" << line << endl;
                           count++;
                           //cout << line;
                           //system("pause");
                           line = "";
                           }
                           }
                     }

    f1.close();
    f2.close();
system("pause");
return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -