Guest User

Untitled

a guest
Nov 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <assert.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. int compile(char *code, int *pointer)
  6. {
  7. if (code == "+") *++pointer;
  8. }
  9.  
  10. int main (int argc, const char *argv[])
  11. {
  12. int *p = malloc(sizeof(int));
  13. *p = 0;
  14.  
  15. compile("+", p);
  16. assert(*p == 1);
  17. compile("-", p);
  18. assert(*p == 0);
  19. compile("++", p);
  20. assert(*p == 2);
  21. compile("--", p);
  22. assert(*p == 0);
  23.  
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment