fork(5) download
  1. #include<functional>
  2. #include<stdio.h>
  3. main() {
  4. char b[30000],g[9999],*f=g,*p=b,n[]="+-,.><[]",j;
  5. std::function<void()>m[256]={
  6. [&p]{(*p)++;},
  7. [&p]{(*p)--;},
  8. [&p]{*p=getchar();},
  9. [&p]{putchar(*p);},
  10. [&p]{p++;},
  11. [&p]{p--;},
  12. [&p,&f]{if(!(*p))while(*f-93)f++;},
  13. [&f,&m]{while(*f-91)f--;m[6]();}
  14. };
  15. fread(g,1,9999,stdin); // fopen("b",0));
  16. for(;*f;f++)for(j=0;n[j];j++)if(n[j]==*f)m[j]();
  17. }
Success #stdin #stdout 0s 3068KB
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!