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

ITT the ABC Programming Language

Name: Anonymous 2008-07-29 19:29

#include <stdio.h>

int main(int argc,char argv*[]){
  int i = 0;
  int BUFFA;

  while(argv[i]!='\0'){
    if(argv[i]='a')
      BUFFA++;
    else if(argv[i]='b')
      BUFFA--;
    else if(argv[i]='c')
      printf("%i\n",BUFFA);
    else printf("%s","Error.\n");
  }
}

Name: Anonymous 2010-08-15 19:55


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

int main(int argc, char **argv) {
        FILE *input;
        int c, acc = 0, ascii = 0;

        if (argc != 2) {
                fprintf(stderr, "usage: %s <file>\n", argv[0]);
                return EXIT_FAILURE;
        }
        if (!(input=fopen(argv[1], "r"))) {
                perror("fopen()");
                return EXIT_FAILURE;
        }

        srand((unsigned)time((time_t *)NULL));

        while ((c=fgetc(input)) != EOF) {
                switch (c) {
#define INSTR(C,X) case (C): (X); break
                        INSTR('a', ++acc);
                        INSTR('b', --acc);
                        INSTR('c', ascii ? putchar(acc) : printf("%d", acc));
                        INSTR('d', acc = rand() / (RAND_MAX / acc +1));
                        INSTR('r', acc *= -1);
                        INSTR('n', acc = 0);
                        INSTR('$', ascii = !ascii);
                        INSTR('l', fseek(input, 0, SEEK_SET));
                        INSTR(';', printf("%d %c\n", acc, acc));
#undef INSTR
                        default:
                                break;
                }
        }
        fclose(input);
        return EXIT_SUCCESS;
}

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