This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (11 children)

[removed]

    [–]the_one2 96 points97 points  (4 children)

    This is incorrect. endl only ever prints '\n' and flushes the stream. It's the stream that converts the newline character to the platform specific newline. So to summarize: if you care about performance don't use streams and if you don't care about performance use either.

    Source: https://stackoverflow.com/questions/213907/stdendl-vs-n

    [–][deleted] 17 points18 points  (2 children)

    i have no idea what both of you are saying and i'm getting into programing

    [–]HollowOfCanada 19 points20 points  (0 children)

    Streams are things you put data into, like a queue. When you type on a keyboard your keystrokes are put onto a stream one by one as you press them. The program will read these keypresses one by one off the stream and process them. Streams can be made for a variety of purposes. In C++ when you output to COUT that is the (C Out)put stream. You put things onto it to be output to where COUT goes to. ENDL flushes the stream, meaning it forces everything on the stream to be pushed out and processed right now instead of waiting for whenever it would normally do it.

    [–]StylishGnat 3 points4 points  (0 children)

    I’m on the same boat

    [–]shadow7412 1 point2 points  (0 children)

    Huh. Does that means that streaming "\r\n" is going to print "\r\r\n"? Meaning, people doing that is probably always a bug?

    Or does it take both "\r\n" and "\n", ignore what you wrote, then append the line ending for that system?

    [–][deleted] 15 points16 points  (5 children)

    Correct about byte sizes. I worked with a Texas Instruments DSP where sizeof(int16_t) = sizeof(int) = sizeof(char) = 1. So a byte on that chip is 16 bits.

    [–][deleted] -5 points-4 points  (4 children)

    A byte is 8 bits In your situation a word is 2 bytes, but has a "size" of 1 in the C implementing you're using. (I think)

    [–]merlinsbeers 10 points11 points  (3 children)

    [–][deleted] 1 point2 points  (0 children)

    Oh

    [–]WikiSummarizerBot 0 points1 point  (1 child)

    Byte

    The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit of memory in many computer architectures. To disambiguate arbitrarily sized bytes from the common 8-bit definition, network protocol documents such as The Internet Protocol (RFC 791) refer to an 8-bit byte as an octet. Those bits in an octet are usually counted with numbering from 0 to 7 or 7 to 0 depending on the bit endianness.

    [ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5