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

What do you code in your free time?

Name: Anonymous 2009-03-20 15:41

I mean, everything has been already done by someone else and I don't think everyone is involved in BIG projects and shit like that.

Name: Anonymous 2009-03-20 20:02

That's not optimized. It might push the same code twice, causing the unpleasant effect of several words in a row having the same formatting. Please fix it by ensuring that two redundant codes can't exist in the stack at the same time.
how would you handle something like [m]a [aa]b [m]c[/m] d[/aa] e[/m]?

anyway, here's a better one:
/* Copyright (c) 2008 Anonymous
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that you grant this
 * same permission to anyone you distribute it to without any additional
 * restrictions.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

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

int main(int argc, char *argv[]){
 char *stack[argc - 1], *bbcode[10] = {"aa", "b", "i", "m", "o", "s", "spoiler",
   "sub", "sup", "u"};
 size_t stack_size = 1, argv_index = 2;
#ifdef __STRICT_ANSI__
 srandom(time(0));
#else
 srandomdev();
#endif
 if(argc == 1) return -1;
 for(printf("[%s]%s", stack[0] = bbcode[random() % 10], argv[1]);
   argv_index < argc; ++argv_index)
  if(random() % 2 && stack_size)
   printf("[/%s] %s", stack[--stack_size], argv[argv_index]);
  else
   printf(" [%s]%s", stack[stack_size++] = bbcode[random() % 10],
     argv[argv_index]);
 while(stack_size) printf("[/%s]", stack[--stack_size]);
 puts("");
 return 0;
}

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