char greeting[] = "Hello world";

Developers: char array... What da f*CK!

... Okay.

How about now? ( ͡° ͜ʖ ͡°)

  • 2
    Honestly i love how C handles strings. Its so simple and so flexible. Just amazing.

    Also honestly use string.h if you dont want to spend half a day writing function for handling and parsing strings.
  • 3
    Also to confuse people even more you could just do char *text = "text"

    Yes i know isnt the same as char text[] = "text" but hey lets not go into that.
  • 0
    Pretending that strings are something they really aren't is what necessitates string builders. If you really handled them by chaining atomic concat operations it would be unusably slow.
  • 1
    @Haxk20 and what is it equivalent to?
  • 0
  • 1
    @Haxk20 well you said let's not go into that, but I was asking about it. what is text *=skfj equivalent to if it is not text[]
    my background is not c++
  • 2
    @krlooss *text is just basically simply said read only char array while text[] you can modify with text[number] = 'character';
  • 1
    utf8 bytes...

    When I read this post my response was:

    What the fuck just happened?
  • 0
    It’s great as long as you do some basic ascii stuff with strings.
    But you will pull your hair out working with utf8 strings if you treat them as char arrays.
    Strings are fucking complex beasts and it’s incredibly hard to make them both simple to use AND behave correctly.
Add Comment