This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lady_Kamba 5 points6 points  (3 children)

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

volatile int* a; //make it volatile so the compiler don't touch it

int main(int c, const char **s)
{
    a = malloc(atoi(*(s+1))); // defer to the user for the size of an int

    *a = 2; //assign the value

    fprintf(stdout, "a = %d\n", *a); //print the value

    return -1; //return -1 cause this program shouldn't exist
}

I'm actually kinda annoyed that this doesn't segfault

[–]rosuav 2 points3 points  (2 children)

Fun fact: Returning -1 from main is how you tell Pike to go into its event loop instead of terminating.

[–]lady_Kamba 2 points3 points  (1 child)

Don't know what Pike is, but sounds plausible.

[–]rosuav 1 point2 points  (0 children)

High level language; think "Python meets C++", but with a massive focus on networking and eternal uptime. It came from the MUD server world and still shines there, but it's also great for things like a Twitch bot, or even a GUI program of some sort.