40

Coded in C language for first time (due to college assignments)...

Just found out that there are no strings in c language 😐

Comments
  • 3
    @njpugh90 there isn't a built in string, I had to use char array
  • 7
    @njpugh90 yeah I did and found the string library <string.h>

    Will use that library next time, thanks ;)
  • 11
    Cstring? That's cheating. Just use a char pointer
  • 3
    @Torbuntu And a char is basically an int. So strings == int array?
  • 2
    @Torbuntu yeah I guess that would be the case.
  • 17
    "C is shit" yeah, tell your OS
  • 5
    @thelegend200 A string is just a null terminated char array at it's core
  • 2
    @Torbuntu strings are blue and they hurt
  • 1
    @Torbuntu you never fail to amuse me with your logic 😂😂😂😂
    Well played 😂
  • 0
    Don't worry c is the best thing to deal with string manipulations
  • 0
    @olback how a char is int??
  • 5
    char a = 'A' ;
    int b = 65;

    printf("%i\n", a); // 65
    printf("%c\n", b); // A

    @Ganofins
  • 1
    @olback no no no... ints are typically 4 bytes, each char is one byte. the string starts at the address allocated and builds out by a byte at a time. List<int> would be closer to what you're describing.
  • 0
    @segfault0xff ah, sorry. I don't know C very well.
  • 3
    Oh dear children. A char array *is* a string in C. Welcome to low-level memory management.
  • 1
    @olback it's more about data structures, not really language specific. There's lots of resources online that go into details. It's really helpful information to have 😊
  • 3
    A char is just a 1-byte unsigned integer. It’s just a number like an int but is called char because it usually corresponds to a character code. This was before Unicode of course. 🙂
  • 0
    @devios1 they're different data types.
  • 0
    @segfault0xff Not that different.
  • 0
    @devios1 different enough to get type mismatch errors
  • 3
    @segfault0xff You can definitely treat a char as a number in C. It's literally just an unsigned byte. You might get a warning if you try to print an int as a character, but you can do that too. C is very flexible.

    C has no primitive bools either. It just uses an int value of 0 or 1 to represent false/true. BOOL is sometimes defined as char.
  • 5
    Correction: anything non-zero is considered true in C. If false is defined as 0, true is more correctly defined as !false, however !0 == 1, so it amounts to the same thing.
  • 0
    @njpugh90 hahaha. I've made the mistake of googling cstring before....
  • 1
    @Torbuntu I mean we all know a computer is a rock we put lighting in then taught how to think....
  • 6
    I will defend C until the day I die. After being made to program in Java OOP for two years during high school without learning the basics of functional programming, C was the saviour of my software career.

    C, I love you.
  • 3
    Yes. Yes strings are a thing in c. That's why

    char helloWorld[32] = "Hello world";

    Automatically fills the char array with those values and ends it with a null terminator. Strings are built into the syntax of the language, they just aren't the high-level bullshit everyone is used to.
  • 0
    Because there's no string data type in processor. In C you use primitive data types like char which is byte. Better be called byte as in c#. You can make array from characters with:
    char string[here goes number of chars];
  • 2
    @dmonkey I use Redox like a real man.
  • 0
    @Proximyst omg 😱 how is it? I'm very curious but sceptical because it's still alpha (is it, right?)
Add Comment