Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Count to 10

Name: Anonymous 2010-06-17 15:14

Lets see if /prog/ can count to 10 in C. I'll start:

int main(void){

Name: Anonymous 2010-06-17 15:15

int i;

Name: Anonymous 2010-06-17 15:16

for (i = 1; i <= 10; ++i) printf("%d\n", i); return 0; }

Let's not import imageboard ``memes''. We have enough shit to deal with as it is.

Name: Anonymous 2010-06-17 15:16

for(i=0; i < 10; i++)

Name: Anonymous 2010-06-17 15:19

i++

Name: Anonymous 2010-06-17 15:19

>>4
Great, now it's a syntax error. Not that it would have gone far, with >>1 forgetting to #include <stdio.h> anyway.

Name: Anonymous 2010-06-17 15:20

#include <stdmeme.h>

Name: Anonymous 2010-06-17 15:20

>>4-5
C++ users haven't read their K&R.

Name: Anonymous 2010-06-17 15:21

return(0);

Name: Anonymous 2010-06-17 15:22

>>9
Good god. If that's how you write C, you need to stop.

Name: Anonymous 2010-06-17 15:24

strcpy(i[3], "Marshland");

Name: Anonymous 2010-06-17 15:25

>>11
THAT IS NOT A STRING!

Name: Anonymous 2010-06-17 15:25

>>1-12

What is wrong with you /prog/? I thought you were better than this.

Name: Anonymous 2010-06-17 15:26

>>10
Valid C code. I jus tried it.

Name: Anonymous 2010-06-17 15:27

>>14
The fact that it compiles doesn't make it valid.

Name: Anonymous 2010-06-17 15:28

>>11
What are you doing? Go sit in the corner.

Name: Anonymous 2010-06-17 15:29

Requesting SAGETANK. May we never speak of this again.

Name: Anonymous 2010-06-17 15:31

I hope this is the work of clever (albeit asinine) trolls.

Name: Anonymous 2010-06-17 15:43

>>18
You idealists always want to see the best in people.

Name: Anonymous 2010-06-17 16:29

>>6
Can't you just stick an #include anywhere? I just started learning C yesterday.

#include <stdio.h>

Fixed?

Name: Anonymous 2010-06-17 16:41

>>20
It's too late! The preprocessor just drops in the .h file where the #include statement is. All the calls inside main will have been to functions that have as of yet undeclared.

Name: Anonymous 2010-06-17 16:44

for loops considered harmful

Name: Anonymous 2010-06-17 16:50

>>22
That's poor grammar. Did you mean ``four loops considered harmful''?

Name: Anonymous 2010-06-17 16:51

>>22
nope

Name: Anonymous 2010-06-17 16:53

>>1-1000,,,,,,,,,,,,
Valid idiot code.

Name: Anonymous 2010-06-17 16:59

>>22
Fun fact for(;;) is faster than while(1).

Name: Anonymous 2010-06-17 17:00

>>21
Oh dear.

Name: Anonymous 2010-06-17 17:06

[borat]Theis thread iz vary niiice![/borat]

Name: Anonymous 2010-06-17 17:08

>>28
Go play in traffic.

Name: Anonymous 2010-06-17 17:09

[b][i][o][u]

Name: Anonymous 2010-06-17 17:10

#include <stdio.h> // all the libraries
#include <stdlib.h>
#include <ctype.h>


int main(void) //this is main, its the second most important function in this program
{
    FILE *ofp; //input and output files
   
    int i, k = 0;
   
    printf("Enter how many data entries you wish to generate:");
    scanf("%d", &k);

    char adj1[10][25];
    char adj2[10][25];
    char adj3[10][25];
    char city[10][25];
   
    strcpy(adj1[0], "Super");
    strcpy(adj1[1], "Dreadful");
    strcpy(adj1[2], "Frozen");
    strcpy(adj1[3], "Scortching");
    strcpy(adj1[4], "Epic");
    strcpy(adj1[5], "Mini");
    strcpy(adj1[6], "Cozy");
    strcpy(adj1[7], "Confusing");
    strcpy(adj1[8], "The");
    strcpy(adj1[9], "Double");
   
    strcpy(adj2[0], "Cold");
    strcpy(adj2[1], "Hot");
    strcpy(adj2[2], "Happy");
    strcpy(adj2[3], "Fairly");
    strcpy(adj2[4], "Vaguely");
    strcpy(adj2[5], "Haunted");
    strcpy(adj2[6], "Trecherous");
    strcpy(adj2[7], "Wonderous");
    strcpy(adj2[8], "Vast");
    strcpy(adj2[9], "Tumbling");
   
    strcpy(adj3[0], "Awesome");
    strcpy(adj3[1], "Goofy");
    strcpy(adj3[2], "Incredible");
    strcpy(adj3[3], "Pleasent");
    strcpy(adj3[4], "Explosive");
    strcpy(adj3[5], "Crazy");
    strcpy(adj3[6], "Special");
    strcpy(adj3[7], "Mega");
    strcpy(adj3[8], "Expensive");
    strcpy(adj3[9], "Dissapointing");
   
    strcpy(city[0], "City");
    strcpy(city[1], "Town");
    strcpy(city[2], "Village");
    strcpy(city[3], "Marshland");
    strcpy(city[4], "Forrest");
    strcpy(city[5], "Mountain");
    strcpy(city[6], "Swamp");
    strcpy(city[7], "Island");
    strcpy(city[8], "Prarie");
    strcpy(city[9], "Beach");   
   
    ofp = fopen("AwesomePlaces.txt","w");
   
    srand(time(NULL));
   
    for(i=0; i<k; i++)
    {
             fprintf(ofp, "%s ", adj1[rand() % 10]);
             fprintf(ofp, "%s ", adj2[rand() % 10]);
             fprintf(ofp, "%s ", adj3[rand() % 10]);
             fprintf(ofp, "%s \n\n", city[rand() % 10]);
    }
   
   fclose(ofp);
  
   system("start AwesomePlaces.txt");
  
  
  return 0;
}

Name: Anonymous 2010-06-17 17:11

>>20 here, am I doing this right?
int main(void) {
#include <stdio.h>
    putchar ('1');
    putchar ('\n');
    putchar ('2');
    putchar ('\n');
    putchar ('3');
    putchar ('\n');
    putchar ('4');
    putchar ('\n');
    putchar ('5');
    putchar ('\n');
    putchar ('6');
    putchar ('\n');
    putchar ('7');
    putchar ('\n');
    putchar ('8');
    putchar ('\n');
    putchar ('9');
    putchar ('\n');
    putchar ('1');
    putchar ('0');
    putchar ('\n');
    return 0;
}

Name: Anonymous 2010-06-17 17:16

while(int i++)
{
printf(i);
}

Name: Anonymous 2010-06-17 17:16

>>33
NOW THATS THE TICKET!     

Name: Anonymous 2010-06-17 17:21

>>33
Go back to using Scheme as a masturbation aid.

Name: Anonymous 2010-06-17 17:23

>>33
Looks like you accidentally the while loop.

Name: Anonymous 2010-06-17 17:24

>>35
Because when you see terrible (!) code, your first impulse is to think that it must be someone who knows Lisp? I think you have a few things backwards.

Name: Anonymous 2010-06-17 18:49

>>37
It is a very widely-known fact that using Lisp for extended periods of time leads to irreversible brain damage.

Name: Anonymous 2010-06-17 19:14

irreversible brain damage
Enlightenment is not (necessarily) brain damage

Name: Anonymous 2010-06-17 19:36


(define (count)
  (define (inner n)
    (if (<= n 10)
        (display n)))
   (inner 1))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List