Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
 Hellfire103   ( @hellfire103@lemmy.ca )  to Programmer Humor@lemmy.mlEnglish · 8 months ago

Does this exist anywhere outside of C++?

lemmy.ml

message-square
32
link
fedilink
105

Does this exist anywhere outside of C++?

lemmy.ml

 Hellfire103   ( @hellfire103@lemmy.ca )  to Programmer Humor@lemmy.mlEnglish · 8 months ago
message-square
32
link
fedilink
alert-triangle
You must log in or # to comment.
  •  jecxjo   ( @jecxjo@midwest.social ) 
    link
    fedilink
    English
    arrow-up
    16
    ·
    8 months ago

    They aren’t the same thing so the comparison is weird.

    endl has a flush which is important when doing something like embedded work or RTOS development. If i was doing multiple lines they all were \n until the last line when i actually want to push the buffer.

    Obviously depending on the tuning of the compiler’s optimization multiple flushes could be reduced but the goal should always be to write as optimal as possible.

    •  lud   ( @lud@lemm.ee ) 
      link
      fedilink
      arrow-up
      3
      ·
      8 months ago

      but the goal should always be to write as optimal as possible.

      Within reason.

      Over optimization is a curse on getting done.

    •  aport   ( @aport@programming.dev ) 
      link
      fedilink
      arrow-up
      3
      ·
      8 months ago

      Who in the hell is using iostreams in an RTOS

      •  KeenFlame   ( @KeenFlame@feddit.nu ) 
        link
        fedilink
        arrow-up
        2
        ·
        8 months ago

        Several. Probably dozens

      •  jecxjo   ( @jecxjo@midwest.social ) 
        link
        fedilink
        English
        arrow-up
        1
        ·
        8 months ago

        Sometimes you work in a codebase that was decided on by others for reasons you don’t know.

  •  UpperBroccoli   ( @UpperBroccoli@lemmy.blahaj.zone ) 
    link
    fedilink
    arrow-up
    14
    ·
    8 months ago

    \n, because I ordered a newline, not a flush.

  •  GideonBear   ( @GideonBear@lemmy.ml ) 
    link
    fedilink
    arrow-up
    13
    ·
    8 months ago

    #define endl “\n”

  •  unlawfulbooger   ( @unlawfulbooger@lemmy.blahaj.zone ) 
    link
    fedilink
    arrow-up
    11
    ·
    8 months ago

    What the heck is endl???

    •  gon [he]   ( @gon@lemm.ee ) 
      link
      fedilink
      English
      arrow-up
      6
      ·
      8 months ago

      https://cplusplus.com/reference/ostream/endl/

      •  unlawfulbooger   ( @unlawfulbooger@lemmy.blahaj.zone ) 
        link
        fedilink
        arrow-up
        11
        ·
        8 months ago

        Boy am I glad I don’t do C++ anymore. That string handling with the overloaded bitshift operator was wild.

        •  vext01   ( @vext01@lemmy.sdf.org ) 
          link
          fedilink
          arrow-up
          1
          ·
          8 months ago

          Ah, so you’re a println! kinda guy?

          •  unlawfulbooger   ( @unlawfulbooger@lemmy.blahaj.zone ) 
            link
            fedilink
            arrow-up
            1
            ·
            8 months ago

            🦀 🦀🦀🦀🦀🦀🦀🦀

      •  SqueakyBeaver   ( @SqueakyBeaver@lemmy.blahaj.zone ) 
        link
        fedilink
        arrow-up
        2
        ·
        8 months ago

        Alternatively:

        https://en.cppreference.com/w/cpp/io/manip/endl

        p.s. The site isn’t entirely mobile friendly

        (I’m a cppref lover tbh)

    •  Hellfire103   ( @hellfire103@lemmy.ca ) OP
      link
      fedilink
      English
      arrow-up
      5
      ·
      8 months ago

      Instead of this:

      std::cout << "Hello world.\n";
      

      You can do this:

      std::cout << "Hello world." << endl;
      
      •  Daedskin   ( @Daedskin@lemm.ee ) 
        link
        fedilink
        arrow-up
        4
        ·
        8 months ago

        The fact that you used the namespace for cout but not for endl inordinately bothers me

      •  ReversalHatchery   ( @ReversalHatchery@beehaw.org ) 
        link
        fedilink
        English
        arrow-up
        1
        ·
        8 months ago

        something has replaced your lessthan signs with their HTML counterparts. such a silly thing to do in a code block

        •  fubbernuckin   ( @fubbernuckin@lemmy.dbzer0.com ) 
          link
          fedilink
          English
          arrow-up
          3
          ·
          8 months ago

          I think that’s client side. Doesn’t happen for me.

          •  Cyberfishofant2   ( @Cyberfishofant2@lemm.ee ) 
            link
            fedilink
            English
            arrow-up
            1
            ·
            8 months ago

            same here. AP isn’t standardized enough, apparently

            •  ReversalHatchery   ( @ReversalHatchery@beehaw.org ) 
              link
              fedilink
              English
              arrow-up
              1
              ·
              8 months ago

              nah its a lemmy app on android that didn’t get an update in ages. probably just uses a faulty markdown renderer

    •  allywilson   ( @allywilson@lemmy.ml ) 
      link
      fedilink
      arrow-up
      3
      ·
      8 months ago

      From memory it’s a way to declare a line ending after your string.

    •  jaybone   ( @jaybone@lemmy.zip ) 
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      God bless your soul.

  •  lengau   ( @lengau@midwest.social ) 
    link
    fedilink
    arrow-up
    8
    ·
    8 months ago

    os.linesep

    Lol jk none of my stuff runs on Windows anyway

  •  Scrubbles   ( @scrubbles@poptalk.scrubbles.tech ) 
    link
    fedilink
    English
    arrow-up
    7
    ·
    8 months ago

    Environment.NewLine()

  •  pewpew   ( @pewpew@feddit.it ) 
    link
    fedilink
    arrow-up
    6
    ·
    8 months ago

    \r\n

  •  SavvyWolf   ( @savvywolf@pawb.social ) 
    link
    fedilink
    English
    arrow-up
    5
    ·
    8 months ago

    https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#lineSeparator--

    Java, of course.

  •  Digital Mark   ( @mdhughes@lemmy.sdf.org ) 
    link
    fedilink
    English
    arrow-up
    5
    ·
    8 months ago

    If you write to a text (as opposed to binary) stream, \n produces \n or \r\n (or \r if old enough) depending on platform just fine.

    Nobody should be using C++ anyway, but plenty of languages have silly system newline constants, which do nothing useful.

  •  nope   ( @nope@jlai.lu ) 
    link
    fedilink
    arrow-up
    5
    ·
    8 months ago

    Environment.NewLine might exist in C#

    •  HiddenLayer555   ( @HiddenLayer555@lemmy.ml ) 
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      Microsoft really creating the problem and then forcing you to use their solution.

  •  lnxtx (xe/xem/xyr)   ( @lnxtx@feddit.nl ) 
    link
    fedilink
    English
    arrow-up
    4
    ·
    8 months ago

    Rebel side \0

  •  bramen49   ( @bramen49@lemmy.ml ) 
    link
    fedilink
    arrow-up
    4
    ·
    8 months ago

    Well, Java has System.lineSeparator so, maybe no?

  •  dave   ( @dave@feddit.uk ) 
    link
    fedilink
    English
    arrow-up
    2
    ·
    8 months ago

    vbCrLf

  •  RandomVideos   ( @RandomVideos@programming.dev ) 
    link
    fedilink
    arrow-up
    2
    ·
    8 months ago

    Endl is faster to type

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 70 users / day
  • 297 users / week
  • 925 users / month
  • 3.03K users / 6 months
  • 867 local subscribers
  • 39.4K subscribers
  • 1.1K Posts
  • 9.83K Comments
  • Modlog
  • mods:
  •  AgreeableLandscape   ( @AgreeableLandscape@lemmy.ml ) 
  •  cat_programmer   ( @cat_programmer@lemmy.ml ) 
  • BE: 0.19.13
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code