Advertisement
Guest User

bolean

a guest
Dec 12th, 2018
2,147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. void buildBool(size_t len, const char* path) {
  2.  
  3.     size_t maxOOOs = len + 2;
  4.     size_t maxSize = 9 + (maxOOOs - 1) + 3 + maxOOOs + 1;
  5.  
  6.     FILE* fl = fopen(path, "w");
  7.  
  8.     size_t off[2];
  9.     off[0] = 11;
  10.     off[1] = 17;
  11.  
  12.     char* strBuf = (char*)malloc(maxSize + 3);
  13.     strBuf[maxSize] = '\0';
  14.  
  15.     memcpy((void*)strBuf, (void*)"typedef b", 9);
  16.  
  17.     for (size_t i = 0; i < len; i++) {
  18.  
  19.         memset(strBuf + 9, 'o', maxSize - 9);
  20.  
  21.         strBuf[off[0]] = 'l';
  22.         strBuf[off[0] + 1] = ' ';
  23.         strBuf[off[0] + 2] = 'b';
  24.  
  25.         strBuf[off[1]] = 'l';
  26.         strBuf[off[1] + 1] = ';';
  27.         strBuf[off[1] + 2] = '\n';
  28.         strBuf[off[1] + 3] = '\0';
  29.  
  30.         off[0]++;
  31.         off[1] += 2;
  32.  
  33.         fwrite(strBuf, 1, strlen(strBuf), fl);
  34.  
  35.     }
  36.  
  37.     free(strBuf);
  38.     fclose(fl);
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement