In C++, am I paying for what I am not eating?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite












Let's consider the following hello world examples in C and C++ :



main.c



#include <stdio.h>

int main()

printf("Hello worldn");
return 0;



main.cpp



#include <iostream>

int main()

std::cout<<"Hello world"<<std::endl;
return 0;



When I compile them in godbolt to assembly, the size of the C code is only 9 lines (gcc -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call puts
xor eax, eax
add rsp, 8
ret


But the size of the C++ code is 22 lines (g++ -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edx, 11
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
xor eax, eax
add rsp, 8
ret
_GLOBAL__sub_I_main:
sub rsp, 8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
add rsp, 8
jmp __cxa_atexit


which is much larger.



It is famous that in C++ you pay for what you eat. So, in this case, what am I paying for?










share|improve this question









New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    You pay for initializing std::cout.
    – Yksisarvinen
    54 mins ago






  • 2




    For using iostream. In this case for std::cout.
    – P.W
    53 mins ago






  • 3




    It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
    – Lundin
    50 mins ago







  • 3




    @Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
    – Vittorio Romeo
    49 mins ago






  • 6




    You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
    – molbdnilo
    45 mins ago















up vote
7
down vote

favorite












Let's consider the following hello world examples in C and C++ :



main.c



#include <stdio.h>

int main()

printf("Hello worldn");
return 0;



main.cpp



#include <iostream>

int main()

std::cout<<"Hello world"<<std::endl;
return 0;



When I compile them in godbolt to assembly, the size of the C code is only 9 lines (gcc -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call puts
xor eax, eax
add rsp, 8
ret


But the size of the C++ code is 22 lines (g++ -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edx, 11
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
xor eax, eax
add rsp, 8
ret
_GLOBAL__sub_I_main:
sub rsp, 8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
add rsp, 8
jmp __cxa_atexit


which is much larger.



It is famous that in C++ you pay for what you eat. So, in this case, what am I paying for?










share|improve this question









New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    You pay for initializing std::cout.
    – Yksisarvinen
    54 mins ago






  • 2




    For using iostream. In this case for std::cout.
    – P.W
    53 mins ago






  • 3




    It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
    – Lundin
    50 mins ago







  • 3




    @Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
    – Vittorio Romeo
    49 mins ago






  • 6




    You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
    – molbdnilo
    45 mins ago













up vote
7
down vote

favorite









up vote
7
down vote

favorite











Let's consider the following hello world examples in C and C++ :



main.c



#include <stdio.h>

int main()

printf("Hello worldn");
return 0;



main.cpp



#include <iostream>

int main()

std::cout<<"Hello world"<<std::endl;
return 0;



When I compile them in godbolt to assembly, the size of the C code is only 9 lines (gcc -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call puts
xor eax, eax
add rsp, 8
ret


But the size of the C++ code is 22 lines (g++ -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edx, 11
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
xor eax, eax
add rsp, 8
ret
_GLOBAL__sub_I_main:
sub rsp, 8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
add rsp, 8
jmp __cxa_atexit


which is much larger.



It is famous that in C++ you pay for what you eat. So, in this case, what am I paying for?










share|improve this question









New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Let's consider the following hello world examples in C and C++ :



main.c



#include <stdio.h>

int main()

printf("Hello worldn");
return 0;



main.cpp



#include <iostream>

int main()

std::cout<<"Hello world"<<std::endl;
return 0;



When I compile them in godbolt to assembly, the size of the C code is only 9 lines (gcc -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call puts
xor eax, eax
add rsp, 8
ret


But the size of the C++ code is 22 lines (g++ -O3):



.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edx, 11
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
xor eax, eax
add rsp, 8
ret
_GLOBAL__sub_I_main:
sub rsp, 8
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
add rsp, 8
jmp __cxa_atexit


which is much larger.



It is famous that in C++ you pay for what you eat. So, in this case, what am I paying for?







c++ c






share|improve this question









New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 39 mins ago









Lundin

101k16147251




101k16147251






New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 55 mins ago









Saher

391




391




New contributor




Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Saher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 3




    You pay for initializing std::cout.
    – Yksisarvinen
    54 mins ago






  • 2




    For using iostream. In this case for std::cout.
    – P.W
    53 mins ago






  • 3




    It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
    – Lundin
    50 mins ago







  • 3




    @Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
    – Vittorio Romeo
    49 mins ago






  • 6




    You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
    – molbdnilo
    45 mins ago













  • 3




    You pay for initializing std::cout.
    – Yksisarvinen
    54 mins ago






  • 2




    For using iostream. In this case for std::cout.
    – P.W
    53 mins ago






  • 3




    It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
    – Lundin
    50 mins ago







  • 3




    @Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
    – Vittorio Romeo
    49 mins ago






  • 6




    You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
    – molbdnilo
    45 mins ago








3




3




You pay for initializing std::cout.
– Yksisarvinen
54 mins ago




You pay for initializing std::cout.
– Yksisarvinen
54 mins ago




2




2




For using iostream. In this case for std::cout.
– P.W
53 mins ago




For using iostream. In this case for std::cout.
– P.W
53 mins ago




3




3




It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
– Lundin
50 mins ago





It's a myth that C++ is equally efficient as C, simple as that. Such believes only work in theory but rarely in practice. That being said, this question isn't answerable unless you post your optimization settings for each compiler.
– Lundin
50 mins ago





3




3




@Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
– Vittorio Romeo
49 mins ago




@Lundin: there's nothing preventing C++ from being as fast as C. Standard Libraries are another matter.
– Vittorio Romeo
49 mins ago




6




6




You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
– molbdnilo
45 mins ago





You are eating cout, so I don't see what you're paying for that you don't eat. That you can still your hunger with either lobster or an egg sandwich doesn't mean that you get to buy the lobster for the same price as an egg sandwich if your goal is just to not be hungry.
– molbdnilo
45 mins ago













2 Answers
2






active

oldest

votes

















up vote
8
down vote














So, in this case, what am I paying for?




std::cout is more powerful and complicated than printf. It supports things like locales, stateful formatting flags, and more.



If you don't need those, use std::printf or std::puts - they're available in <cstdio>.





It is famous that in C++ you pay for what you eat.




I also want to make it clear that C++ != The C++ Standard Library. The Standard Library is supposed to be general-purpose and "fast enough", but it will often be slower than a specialized implementation of what you need.



On the other hand, the C++ language strives to make it possible to write code without paying unnecessary extra hidden costs (e.g. opt-in virtual, no garbage collection).






share|improve this answer




















  • I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
    – lisyarus
    36 mins ago










  • @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
    – Lundin
    18 mins ago






  • 1




    @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
    – lisyarus
    10 mins ago


















up vote
3
down vote













The Input / Output functions in C++ are elegantly written and are designed so they are simple to use. In many respects they are a showcase for the object-orientated features in C++.



But you do indeed give up a bit of performance in return, but that's negligible compared to the time taken by your operating system to handle the functions at a lower level.



You can always fall back to the C style functions as they are part of the C++ standard, or perhaps give up portability altogether and use direct calls to your operating system.






share|improve this answer






















    Your Answer





    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Saher is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52442415%2fin-c-am-i-paying-for-what-i-am-not-eating%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    8
    down vote














    So, in this case, what am I paying for?




    std::cout is more powerful and complicated than printf. It supports things like locales, stateful formatting flags, and more.



    If you don't need those, use std::printf or std::puts - they're available in <cstdio>.





    It is famous that in C++ you pay for what you eat.




    I also want to make it clear that C++ != The C++ Standard Library. The Standard Library is supposed to be general-purpose and "fast enough", but it will often be slower than a specialized implementation of what you need.



    On the other hand, the C++ language strives to make it possible to write code without paying unnecessary extra hidden costs (e.g. opt-in virtual, no garbage collection).






    share|improve this answer




















    • I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
      – lisyarus
      36 mins ago










    • @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
      – Lundin
      18 mins ago






    • 1




      @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
      – lisyarus
      10 mins ago















    up vote
    8
    down vote














    So, in this case, what am I paying for?




    std::cout is more powerful and complicated than printf. It supports things like locales, stateful formatting flags, and more.



    If you don't need those, use std::printf or std::puts - they're available in <cstdio>.





    It is famous that in C++ you pay for what you eat.




    I also want to make it clear that C++ != The C++ Standard Library. The Standard Library is supposed to be general-purpose and "fast enough", but it will often be slower than a specialized implementation of what you need.



    On the other hand, the C++ language strives to make it possible to write code without paying unnecessary extra hidden costs (e.g. opt-in virtual, no garbage collection).






    share|improve this answer




















    • I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
      – lisyarus
      36 mins ago










    • @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
      – Lundin
      18 mins ago






    • 1




      @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
      – lisyarus
      10 mins ago













    up vote
    8
    down vote










    up vote
    8
    down vote










    So, in this case, what am I paying for?




    std::cout is more powerful and complicated than printf. It supports things like locales, stateful formatting flags, and more.



    If you don't need those, use std::printf or std::puts - they're available in <cstdio>.





    It is famous that in C++ you pay for what you eat.




    I also want to make it clear that C++ != The C++ Standard Library. The Standard Library is supposed to be general-purpose and "fast enough", but it will often be slower than a specialized implementation of what you need.



    On the other hand, the C++ language strives to make it possible to write code without paying unnecessary extra hidden costs (e.g. opt-in virtual, no garbage collection).






    share|improve this answer













    So, in this case, what am I paying for?




    std::cout is more powerful and complicated than printf. It supports things like locales, stateful formatting flags, and more.



    If you don't need those, use std::printf or std::puts - they're available in <cstdio>.





    It is famous that in C++ you pay for what you eat.




    I also want to make it clear that C++ != The C++ Standard Library. The Standard Library is supposed to be general-purpose and "fast enough", but it will often be slower than a specialized implementation of what you need.



    On the other hand, the C++ language strives to make it possible to write code without paying unnecessary extra hidden costs (e.g. opt-in virtual, no garbage collection).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 53 mins ago









    Vittorio Romeo

    51.3k14137273




    51.3k14137273











    • I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
      – lisyarus
      36 mins ago










    • @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
      – Lundin
      18 mins ago






    • 1




      @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
      – lisyarus
      10 mins ago

















    • I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
      – lisyarus
      36 mins ago










    • @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
      – Lundin
      18 mins ago






    • 1




      @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
      – lisyarus
      10 mins ago
















    I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
    – lisyarus
    36 mins ago




    I think it is worth mentioning that one major advantage of streams as opposed to printf is that they can be taught to work with arbitrary types.
    – lisyarus
    36 mins ago












    @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
    – Lundin
    18 mins ago




    @lisyarus The format string of printf is variable, so that's a weak argument. The real advantage with iostream is rather that it's somewhat robust, while stdio is a museum of the most dangerous functions ever designed in the history of programming.
    – Lundin
    18 mins ago




    1




    1




    @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
    – lisyarus
    10 mins ago





    @Lundin Yes, but you can't teach printf how to print a user-defined type instead of specifying the format every time (you can in some implementations, but, as far as I know, it is not recommended to use this feature). With streams, you can just put another overload of operator << without the need to repeat yourself. Of course, I agree that safety is another major advantage, in some cases the major one.
    – lisyarus
    10 mins ago













    up vote
    3
    down vote













    The Input / Output functions in C++ are elegantly written and are designed so they are simple to use. In many respects they are a showcase for the object-orientated features in C++.



    But you do indeed give up a bit of performance in return, but that's negligible compared to the time taken by your operating system to handle the functions at a lower level.



    You can always fall back to the C style functions as they are part of the C++ standard, or perhaps give up portability altogether and use direct calls to your operating system.






    share|improve this answer


























      up vote
      3
      down vote













      The Input / Output functions in C++ are elegantly written and are designed so they are simple to use. In many respects they are a showcase for the object-orientated features in C++.



      But you do indeed give up a bit of performance in return, but that's negligible compared to the time taken by your operating system to handle the functions at a lower level.



      You can always fall back to the C style functions as they are part of the C++ standard, or perhaps give up portability altogether and use direct calls to your operating system.






      share|improve this answer
























        up vote
        3
        down vote










        up vote
        3
        down vote









        The Input / Output functions in C++ are elegantly written and are designed so they are simple to use. In many respects they are a showcase for the object-orientated features in C++.



        But you do indeed give up a bit of performance in return, but that's negligible compared to the time taken by your operating system to handle the functions at a lower level.



        You can always fall back to the C style functions as they are part of the C++ standard, or perhaps give up portability altogether and use direct calls to your operating system.






        share|improve this answer














        The Input / Output functions in C++ are elegantly written and are designed so they are simple to use. In many respects they are a showcase for the object-orientated features in C++.



        But you do indeed give up a bit of performance in return, but that's negligible compared to the time taken by your operating system to handle the functions at a lower level.



        You can always fall back to the C style functions as they are part of the C++ standard, or perhaps give up portability altogether and use direct calls to your operating system.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 40 mins ago

























        answered 52 mins ago









        Bathsheba

        168k26238354




        168k26238354




















            Saher is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Saher is a new contributor. Be nice, and check out our Code of Conduct.












            Saher is a new contributor. Be nice, and check out our Code of Conduct.











            Saher is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52442415%2fin-c-am-i-paying-for-what-i-am-not-eating%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery