What The Difference between stdio.h and iostream? [duplicate]

问题: This question already has an answer here: 'printf' vs. 'cout' in C++ 16 answers #include<stdio.h> int main () { // code } return 0 ; #...

问题:

This question already has an answer here:

#include<stdio.h>
int main ()
{
    // code
}
return 0 ;
#include<iostream>
int main ()
{
    // code
}

Which library is best to use?

What is the best and why? And when I code what is the difference in function between them?


回答1:

stdio.h is the header file in the C standard library. It is used for input/output

iostream is the input output class in C++

So if you're using C++ just use #include <iostream>


回答2:

First off, iostream is part of the C++ standard library, and stdio.h is part of the C standard library. While stdio.h will work in C++ it does not provide everything that iostream includes as iostream is specifically for C++.

Here is stdio.h documentation.

Here is iostream documentation.


回答3:

iostream is the C++ header for the input / output classes and objects (std::cout, std::cin...). stdio.h is the C header for printf, scanf, ... (in C++, stdio.h became cstdio)

In C++, you are not supposed to use it, use iostream instead.

  • 发表于 2019-01-15 00:27
  • 阅读 ( 174 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除