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

📄 文件读取.cpp

📁 包含几十个有关数据结构算法的源代码 包括栈 队列 树图等 是初学者的最佳选择
💻 CPP
字号:
#include <iostream.h> 
#include <stdlib.h> 
#include <stdio.h>
#include <fstream.h> 

int main() 
{ 


     short i=1; 
     char buf[100]; 
     ifstream aa("aa.txt"); 

     while (1) { 
            
           cout << i++ << ':' ; 
           aa.seekg(0,ios::beg);//第二次循环到不了文件头,用aa.rdbuf可以显示其余的内容,但我不会按行处理其中的内容。 
           while(aa.getline(buf,100)) { 
               cout << buf << endl; 

           } 
           cout << "Please press any key to continue..."; 
           cin.get(); 
     } 

     return 0; 
} 

⌨️ 快捷键说明

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