Guest User

Untitled

a guest
Aug 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int *base = malloc(20);
  6. short c;
  7. for(c=0; c<20; c++) {
  8. base[c] = 0;
  9. }
  10. short values[6] = {94, 72, 103, 36, 38, 102};
  11. for(c=0;c<=(sizeof(values) /sizeof(short));c++) {
  12. // supports numbers under 1000
  13. short unitval = values[c] % 10;
  14. if (*(base + (unitval * 4) + 2)) {
  15. //memory address free
  16. *(base + (unitval * 4) + 2) = values[c];
  17. }
  18. else {
  19. //isn't free checks flag and then moves through
  20. if (*(short *)(base + (unitval * 4))) {
  21. //flag set (overwriting)
  22. *(short *)(base + (unitval * 4)) = values[c];
  23. }
  24. else {
  25. short c1;
  26. }
  27. }
  28. }
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment