C ++ I / O文件流优于C语言

时间:2017-07-23 08:01:25

标签: c++ c oop

为文件指定对象而不是为其指定指针有什么好处? OOP 如何通过这种声明方式帮助我们? 在C ++文件中以这种方式读取(它有obejct)

#include <iostream>
#include <fstream>
int main()
{
    ifstream InFile;
    InFile.open("/* directory*/");
}

而在C语言中,你声明一个指针,然后做你想做的任何事情。

   *#include <stdio.h>
      int main()
      { 
           FILE *fptr;
           fptr= fopen("/* directory*/");
           /*..
           .
           .*/
          return 0;
      }

我感谢任何好的答案。

1 个答案:

答案 0 :(得分:1)

FILE是一种数据结构,它获取有关os中文件结构的信息。因此,如果您想使用文件,则必须使用该文件定义变量指针。

文件定义:

typedef struct _iobuf
    {
        void* _Placeholder;
    } FILE;
相关问题