Fast HTTP download, need a little help

This is a discussion on Fast HTTP download, need a little help within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Dino [/code] (I did change this one line: Code: cout << "In main thread." << '\n' << ...

  1. #16
    Registered User
    Join Date
    Oct 2006
    Posts
    2,402
    Quote Originally Posted by Dino View Post
    [/code]
    (I did change this one line:
    Code:
     cout << "In main thread." << '\n' << std::endl;
    the \n is completely unnecessary. std::endl does exactly the same thing, and is portable. on all platforms it will be the endline character(s) for the current platform. on some it's \r\n, and others it's just \n. what's interesting is that in that line, the program is making several function calls behind the scenes. it's writing "In main thread." to std::cout, and then it's writing std::endl. this means that the thread scheduler can interrupt between them, and you could get something else printed between "In main thread." and std::endl, unless you're using mutexes.

  2. #17
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Quote Originally Posted by Elkvis View Post
    the \n is completely unnecessary. std::endl does exactly the same thing, and is portable. on all platforms it will be the endline character(s) for the current platform. on some it's \r\n, and others it's just \n. what's interesting is that in that line, the program is making several function calls behind the scenes. it's writing "In main thread." to std::cout, and then it's writing std::endl. this means that the thread scheduler can interrupt between them, and you could get something else printed between "In main thread." and std::endl, unless you're using mutexes.
    I know that - I just was being totally up front in posting my output so that when you saw the extra line break, you didn't freak out. Adding the \n was just a little "what if" test I did when observing the behavior.

    Thanks again for the tutorial! A condensed, clean up version of this thread should go in the FAQs.

    Todd
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Download File through HTTP Proxy
    By cyberCLoWn in forum Windows Programming
    Replies: 6
    Last Post: 06-19-2007, 01:40 AM
  2. http download
    By keeper in forum C++ Programming
    Replies: 11
    Last Post: 05-24-2006, 05:11 AM
  3. Replies: 4
    Last Post: 09-30-2005, 02:51 AM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21