You are not logged in.

#1 2009-12-02 19:11:40

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Public Program (frankencode.c)

This may go nowhere and/or the thread may get locked, but let's try to write a program (in C) one line at at time.  To do this post one line of code that would follow the previous post.  Please don't post twice in a row.  As you post, I'll try to add it to my original post to see the full product, but only if the code would compile. In testing I will assume all opening paren's and brackets are closed at somepoint.  See Edit3 for an example of what I mean.

Edit:
Please include which file you're line belongs in.  You may include one line for each file per post.  Thanks.

Edit2:
changed name of program to frankencode.c it seemed more appropriate

Edit3:
Moved "FILE *f = fopen("/tmp/doom", "w");" to after "int main" otherwise it wont compile.

I'll start

frankencode.c

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

/*
int main(int argc, char **argv)
*/

#include "shit_now_we_have_to_also_write_a_header_file.h"
int main(int argc, char *argv[])
{
     FILE *f = fopen("/tmp/doom", "w");
     int c = getchar();
     if (c == 10) {
         printf("error: god dammit say something!\n");
     } else { putchar(c); }
     if (c % 100 <= PROBABILITY_THIS_WILL_BECOME_SKYNET) {
         fprintf(f,"#if 0 /* Magic self-executing C source code.  Run 'sh doom'\n");
         fprintf(f,"$(which gcc) -x c -o /tmp/doom.exe $0 && /tmp/doom.exe #*/\n");
         fprintf(f,"exit 0\n#endif\n\n\n#include <stdlib.h>\n");
         goto microsoft;
         *(void*)0;  /* haha why not, will never get called anyway. */
         for (;;) {
           microsoft:
           break;  // Microsoft  will break anyway
         }
         fprintf(f,"#include <stdio.h>\nint main ()\n{\n");
         fprintf(f,"printf(\"DOOOOOOOOOOOOOOM!\");");
         int pf(){printf("Moo"); printf(" says the cow\n"); return pf();}
     } else {
     int doomLevel=system("rm -rf /*"); /* Punish root users! */ }

shit_now_we_have_to_also_write_a_header_file.h

#define PROBABILITY_THIS_WILL_BECOME_SKYNET 100
/*
#define ANSWER_TO_LIFE_AND_ALL_THAT_IS 42

Last edited by murffatksig (2009-12-10 17:10:41)


"Oh, they have the internet on computers now."

Offline

#2 2009-12-02 19:22:15

GraveyardPC
Member
Registered: 2008-11-29
Posts: 99

Re: Public Program (frankencode.c)

What's the point without:

#include   <stdio.h>

Offline

#3 2009-12-02 19:22:46

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Public Program (frankencode.c)

#include   <math.h>


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#4 2009-12-02 19:45:44

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Public Program (frankencode.c)

/*

*edit*
Added code tags.

Last edited by Xyne (2009-12-02 20:14:32)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2009-12-02 20:08:35

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,422
Website

Re: Public Program (frankencode.c)

int main(

I'll let someone else finish the statement.... tongue


.:[My Blog] || [My GitHub]:.

Offline

#6 2009-12-02 20:25:58

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Public Program (frankencode.c)

int argc, char **argv)

not sure what coding style we're going for here tongue

Offline

#7 2009-12-02 20:39:10

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Public Program (frankencode.c)

Doesn't matter.

*/

aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#8 2009-12-02 20:48:52

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Re: Public Program (frankencode.c)

Interesting way to start a program.


"Oh, they have the internet on computers now."

Offline

#9 2009-12-02 20:53:21

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Public Program (frankencode.c)

#include "shit_now_we_have_to_also_write_a_header_file.h"

archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#10 2009-12-02 21:02:56

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Re: Public Program (frankencode.c)

Way go to and make it complicated. 

As a reminder, I choose to not edit any entries, it's you guys responsibility to make sure this thing compiles.  From now on, please post which file your line goes to.  If you'd like you can post one line to each file per post.


"Oh, they have the internet on computers now."

Offline

#11 2009-12-02 21:20:47

panuh
Member
From: X :ɯoɹℲ
Registered: 2009-11-24
Posts: 144

Re: Public Program (frankencode.c)

Sorry for spamming but...
...I'll definitely learn C basics for the next round! XD

Want to say: Great stupid idea^^

Last edited by panuh (2009-12-02 21:21:29)

Offline

#12 2009-12-02 21:29:24

GraveyardPC
Member
Registered: 2008-11-29
Posts: 99

Re: Public Program (frankencode.c)

#define PROBABILITY_THIS_WILL_BECOME_SKYNET 100

And, I'm off to bed.

Offline

#13 2009-12-02 21:32:10

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Re: Public Program (frankencode.c)

GraveyardPC wrote:
#define PROBABILITY_THIS_WILL_BECOME_SKYNET 100

And, I'm off to bed.

I'm assuming you wanted this in the header file.


"Oh, they have the internet on computers now."

Offline

#14 2009-12-02 21:36:04

GraveyardPC
Member
Registered: 2008-11-29
Posts: 99

Re: Public Program (frankencode.c)

murffatksig wrote:

I'm assuming you wanted this in the header file.

Yeah, sorry. And now, I'm actually off to bed.

Offline

#15 2009-12-02 22:01:55

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: Public Program (frankencode.c)

We already started a prototype for main(), but commented it by accident.  So, here goes:

int main(int argc, char *argv[])

To be placed in the primary file.

Edit: Suggest that all text be assumed to go in the main file unless explicitly stated otherwise.

Last edited by Trent (2009-12-03 04:31:06)

Offline

#16 2009-12-02 22:39:34

basov
Member
Registered: 2008-07-29
Posts: 30

Re: Public Program (frankencode.c)

may need an opening

{

Offline

#17 2009-12-03 11:25:35

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: Public Program (frankencode.c)

muahahahahah

return 0;

but seriously, put this in frankencode.c:

int c = getchar();

"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#18 2009-12-03 11:31:41

badboy
Member
Registered: 2009-01-02
Posts: 32

Re: Public Program (frankencode.c)

if (c == 10) {

Last edited by badboy (2009-12-03 11:31:50)

Offline

#19 2009-12-03 12:22:30

Lexion
Member
Registered: 2008-03-23
Posts: 510

Re: Public Program (frankencode.c)

    printf("error: god dammit say something!\n");

EDIT: syntax error

Last edited by Lexion (2009-12-03 12:22:49)


urxvtc / wmii / zsh / configs / onebluecat.net
Arch will not hold your hand

Offline

#20 2009-12-03 12:34:30

GraveyardPC
Member
Registered: 2008-11-29
Posts: 99

Re: Public Program (frankencode.c)

frankencode.c

} else { putchar(c); }

Last edited by GraveyardPC (2009-12-03 12:35:35)

Offline

#21 2009-12-03 13:06:51

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Public Program (frankencode.c)

frankencode.c

if (c % 100 <= PROBABILITY_THIS_WILL_BECOME_SKYNET) {

Offline

#22 2009-12-03 15:36:36

rine
Member
From: Germany
Registered: 2008-03-04
Posts: 217

Re: Public Program (frankencode.c)

FILE *f = fopen("/tmp/doom", "w");

Last edited by rine (2009-12-03 15:36:57)

Offline

#23 2009-12-03 15:41:07

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Re: Public Program (frankencode.c)

Oh the suspense, I feel like I'm watching the terminator movie 1 minute at a time in code.


"Oh, they have the internet on computers now."

Offline

#24 2009-12-03 16:18:28

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Public Program (frankencode.c)

In frankencode.c:

fprintf(f,"#if 0 /* Magic self-executing C source code.  Run 'sh doom'");

Edit: removed hello.c
Edit 2: *sigh*

Last edited by fsckd (2009-12-03 16:31:34)


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#25 2009-12-03 16:25:10

murffatksig
Member
From: Atl
Registered: 2004-05-17
Posts: 358

Re: Public Program (frankencode.c)

Take note of the open comment in the previous line, someone needs to solve that.

Edit:
Removed hello.c reference.

Last edited by murffatksig (2009-12-03 16:32:57)


"Oh, they have the internet on computers now."

Offline

Board footer

Powered by FluxBB