fork(1) download
  1. #include<functional>
  2. #include<stdio.h>
  3. main(int c,char **a) {
  4. char b[30000],g[9999],*f=g,*r=f,*p=b;
  5. std::function<void()>m[256];
  6. m['>']=[&p]{p++;};
  7. m['<']=[&p]{p--;};
  8. m['+']=[&p]{(*p)++;};
  9. m['-']=[&p]{(*p)--;};
  10. m['.']=[&p]{putchar(*p);};
  11. m[',']=[&p]{*p=getchar();};
  12. m['[']=[&p,&r,&f]{*p?r=f-1:r=0;};
  13. m[']']=[&r,&f]{r?f=r:r=f;};
  14. fread(g,1,9999,stdin); // fopen(a[1],"r"));
  15. while (c=*(f++))if(m[c]&&(r||c==']'))m[c]();
  16. }
Success #stdin #stdout 0s 3024KB
stdin
+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2 
    > +++                   add  3 to cell #3
    > +                     add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                  print 'H'
> + .                   print 'e'
+++++ ++ .              print 'l'
.                       print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'
stdout
Hello World!