c++ read

#include <fstream>
#include <iostream>

int main(void) {
    char url[1000] = {0};
    int buff_len = 1000;
    std::ifstream read("./urls");

    if (!read) { // 这跟python语法相似啊
        std::cout << "open file err!" << std::endl;
        return -1;
    }

    while( !(read.peek() == EOF) ) {
        read.getline(url, buff_len);
        std::cout << url << std::endl;
    }

    read.close();
}

 

posted on 2015-11-04 04:48  雨渐渐  阅读(1728)  评论(0编辑  收藏  举报

导航