Thread: Fast HTTP download, need a little help

  1. #16
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    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
    Chappell Hill, Texas
    Posts
    2,332
    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
    Mainframe assembler programmer by trade. C coder when I can.

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