Communities

IMECC
IMECC
MA111
MA211
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Procurar help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A Teste de "syntax highlighting"

Teste de "syntax highlighting": #include <stdlib.h> #include <stdio.h> #include <errno.h> #define KNOWN_GARBAGE ((int*)~0u) int main (void) { int* ptr = KNOWN_GARBAGE...

0 answers  ·  posted 10d ago by Rodolfo Broco Manin‭

Question geral
#1: Initial revision by user avatar Rodolfo Broco Manin‭ · 2024-10-11T15:50:25-03:00 (10 days ago)
Teste de "syntax highlighting"
Teste de "syntax highlighting":

```
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#define KNOWN_GARBAGE ((int*)~0u)

int main (void)
{
  int* ptr = KNOWN_GARBAGE;
  ptr = malloc(0);
  int errno_changed = errno;

  if(ptr == NULL)
    puts("Returned NULL.");
  else if(ptr == KNOWN_GARBAGE)
    puts("Didn't modify the pointer, non-conforming?");
  else
    puts("Returned non-zero, modified the pointer.");
  if(errno_changed)
    printf("Weird use of errno detected, error code 0x%X\n", errno_changed);
}
```

copiado de: https://software.codidact.com/posts/292694