Jellie Frontier
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Hellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 3 months ago

Does this exist anywhere outside of C++?

lemmy.ml

external-link
message-square
23
fedilink
115
external-link

Does this exist anywhere outside of C++?

lemmy.ml

Hellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 3 months ago
message-square
23
fedilink
alert-triangle
You must log in or register to comment.
  • SpaceNoodle@lemmy.world
    link
    fedilink
    arrow-up
    37
    arrow-down
    3
    ·
    edit-2
    3 months ago

    If I’m writing C++, I’m usually optimizing for portability over performance, in which case I would prefer std::endl as it would yield the best results regardless of platform; it also keeps the end-of-line character out of other strings, making code just a little cleaner.

    \n is for when I’m done pretending that anything that isn’t Unix-like is OK, and I’m counting the cycles of every branch instruction.

  • UpperBroccoli@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    16
    ·
    3 months ago

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

  • unlawfulbooger@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    15
    ·
    3 months ago

    What the heck is endl???

    • vapeloki@lemmy.world
      link
      fedilink
      arrow-up
      30
      ·
      3 months ago

      std::endl is used in output streams in C++ to end the line, using the os specific line termination sequence, and flush the buffer.

      The later one is a performance issue in many cases, why the use of "\n" is considered preferred

    • Hellfire103@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      11
      ·
      edit-2
      3 months ago

      Instead of this:

      cout << "Hello world.\n";
      

      You can do this:

      cout << "Hello world." << endl;
      
      • Daedskin@lemm.ee
        link
        fedilink
        arrow-up
        6
        ·
        3 months ago

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

    • gon [he]@lemm.ee
      link
      fedilink
      English
      arrow-up
      5
      ·
      3 months ago

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

      • unlawfulbooger@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        5
        arrow-down
        1
        ·
        3 months ago

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

      • SqueakyBeaver@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        2
        ·
        3 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)

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

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

    • jaybone@lemmy.zip
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      God bless your soul.

  • GideonBear@lemmy.ml
    link
    fedilink
    arrow-up
    13
    ·
    3 months ago

    #define endl “\n”

  • besselj@lemmy.ca
    link
    fedilink
    arrow-up
    9
    arrow-down
    2
    ·
    3 months ago

    \r\n gang

    • SpaceNoodle@lemmy.world
      link
      fedilink
      arrow-up
      9
      arrow-down
      1
      ·
      3 months ago

      Get out

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        3 months ago

        Yeah \r gang4lyfe

    • aport@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      Are you a modem by any chance?

      • besselj@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        No, I’m a teapot

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    ·
    3 months ago

    I’m on side \PHP_EOL

    • grandel@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      I like that you added the absolute namespace identifier or whatever its called

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        I don’t always namespace but when I do I fully qualify.

  • dave@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 months ago

    vbCrLf

  • RandomVideos@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    Endl is faster to type

  • bramen49@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

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

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.

  • 193 users / day
  • 624 users / week
  • 1.81K users / month
  • 6.19K users / 6 months
  • 1 local subscriber
  • 36.9K subscribers
  • 645 Posts
  • 2.12K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org