c++将文本中的字符串一次读入到内存

这段代码是将文本文件中的全部字符读入到内存中,这样的速度是很快的

    char buf[1024*800];
    int MAXS = 10000000;
    freopen("d:\\4.txt", "rb", stdin);
    int len = fread(buf, 1, 100000, stdin);
    buf[len] = '\0';
    cout << buf[10];

 

posted @ 2015-05-04 22:20  杰骜不驯  阅读(298)  评论(0编辑  收藏  举报