Midwest Dev Chat


  • The newest 15 messages in the super-cool #c-or-cpp channel.

  • 11/29 16:19:08 Chas: so you'd probably want
  • 11/29 16:20:17 Chas:
      char **inp3_ = malloc(sizeof(char *)*5);
      inp3_[4] = NULL;
      for (char **ptr_ = inp3_; *ptr_ != NULL; ptr_++) ...
  • 11/29 16:20:54 Chas: '\0' kinda ends up working, it is a char, but it is also numerically zero, so the type is wrong, but the comparison ends up the same
  • 11/29 16:21:38 Chas: but there isn't necessarily a zero in your example, so it is primed for running on forever dumping all of memory slightly_smiling_face
  • 11/29 16:22:13 Long: @Jolyn That was a really helpful link. Thanks.
  • 11/29 16:22:17 Madge: gotta love those out of bound issues
  • 11/29 16:22:35 Chas: i also really don't understand why `char *x = "abc"` isn't giving a warning in clang
  • 11/29 16:23:02 Chas: but string literals are const, and if you tried to write to it, you'll likely get a bus error or something along those lines
  • 11/29 16:24:05 Chas:
     #include <stdio.h>
     #include <stdlib.h>
    int main(int argc, char *argv[])
      char *x = "abc";
      x[0] = 'b';
      printf("%s\n", x);
      return EXIT_SUCCESS;
    clang gives no warnings with `-Wall -Wextra` but dies with a bus error
  • 11/29 16:24:27 Long: I'm compiling with gcc. also noted in regards to string literals being constant.
  • 11/29 16:25:06 Chas: gcc doesn't give a warning on that one either
  • 11/29 16:25:18 Chas: and segfaults on linux
  • 11/29 16:25:18 Jolyn: >@Jolyn That was a really helpful link. Thanks. you can thank `jroseberry1` from devICT slack.
  • 11/29 16:25:40 Jolyn: (or you can't because he's not on here. lol)
  • 11/29 16:51:35 Long: so my cumulative compilation error log now stands at 523K, That is with 300 compiled code snippets, (some compiled multiple times). once I get into file operations chapter in with the text book i'm studying c programming in. I'll be able to parse the error log out to study my errors and warnings. fun: yay.
  • *Usernames have been changed to protect the innocent.
We're currently 1114 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!