zoukankan      html  css  js  c++  java
  • fopen_s在文件中读写字符串

    #include "stdafx.h"
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <cstdlib>
    using namespace std;
    int main()
    {
    FILE *fp;
    errno_t err = fopen_s(&fp, "D://1.TXT", "rt"); //读取文件数据
    cout << err << endl;
    
    char s[2];
    int index = 0;
    while (!feof(fp))
    {
    
    //fscanf_s(fp, "%c",&s);读取字符方式一
    //if (fread(s, 1, 2, fp) == 0) break;读取字符串方式二,一次读取两个
    
    index++;
    cout << (s[0])<<s[1];
    }
    cout << endl;
    cout << index;
    fclose(fp);
    
    }
  • 相关阅读:
    Multidimensional Arrays
    TortoiseGit
    Excel教程(14)
    Excel教程(13)
    Excel教程(12)
    Excel教程(11)
    lock
    reflect
    game
    html x
  • 原文地址:https://www.cnblogs.com/Isesame/p/11008926.html
Copyright © 2011-2022 走看看