Share good ideas and conversation.   Login, Join Us, or Take a Tour!
comment by Devac
Devac  ·  685 days ago  ·  link  ·    ·  parent  ·  post: Ph.D. students face significant mental health challenges

Not even the stuff written after two spaces of indentation is displayed verbatim.

  There are no escape characters in C.

Which is unfortunate. It's actually supposed to be C++.




bfv  ·  685 days ago  ·  link  ·  

In this one instance I say it's a feature, not a bug ;)

Devac  ·  685 days ago  ·  link  ·  

Oh, now you're just being reasonable about a language that allows you to commit some proper code-atrocities:

  #include <stdio.h>

#include <stdlib.h>

  int main(void)

{

char * str = (char*)malloc(1);

free((void*)(str[10] = '\0'));

str[1] = 'a';

printf("%s", str);

free((void*)str);

return 0;

}

This compiles and doesn't cause segfault. Believe me, I get what you are saying.

EDIT: Changed the allocated amount of space, not that it mattered to the compiler…