Advertisement
gur111

Hadar/Yahav test.c

Jul 12th, 2020
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.99 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdarg.h>
  4.  
  5.  
  6. // Source: https://www.tutorialspoint.com/cprogramming/c_variable_arguments.htm
  7. double average(int num, ...) {
  8.  
  9.    va_list valist;
  10.    double sum = 0.0;
  11.    int i;
  12.  
  13.    /* initialize valist for num number of arguments */
  14.    va_start(valist, num);
  15.  
  16.    /* access all the arguments assigned to valist */
  17.    for (i = 0; i < num; i++) {
  18.       sum += va_arg(valist, int);
  19.    }
  20.    
  21.    /* clean memory reserved for valist */
  22.    va_end(valist);
  23.  
  24.    return sum/num;
  25. }
  26.  
  27.  
  28. struct a_t{
  29. };
  30.  
  31.  
  32. int a(const struct a_t *param){
  33.     printf("A\n");
  34.     return 1;
  35. }
  36.  
  37. int b(int *count){
  38.     // count == 0x100
  39.     (*count)++;
  40.     printf("b\n");
  41.     return 1;
  42. }
  43.  
  44.  
  45. int main(int argc, int **argv){
  46.     // Calculated left to right
  47.     // + / * -
  48.     //  condition ? true-statement: false-statement
  49.     // == != > < <= >=
  50.  
  51.     // Calculated right to left
  52.     // =
  53.     // See table: https://www.tutorialspoint.com/cprogramming/c_operators_precedence.htm
  54.  
  55.     //             V
  56.     // obj   count  int  int  int
  57.     // 0x100 0x100 0000 0000 0000 0000
  58.  
  59.     // int arr[10];
  60.     // type(((double *) arr)+1) == int *
  61.     // int i = 0;
  62.     // int j = 0;
  63.     // // 0 + 0
  64.     // int *obj = &i; // Assume 0x100
  65.     // b(obj);
  66.     // printf("%d", /* CENCORED  */);
  67.     printf("%c ", 'p' + 'z' - 'w');
  68. }
  69.  
  70. // 001010011
  71. // 010101001
  72. // 011111010
  73.  
  74.  
  75. // a = 0100
  76. // b = 1110
  77. // a2= 1010
  78.  
  79. // data = 0101011101010100101010
  80. // mask = 1111111111111111111111
  81. // mask = 1111111111111111111111
  82. //        0101011101010100101010
  83.  
  84. // enctypted = data^mask
  85. // decrypted = encrypted^mask
  86.  
  87. // a ^= b ^= a ^= b
  88. // a_xor_b = a ^ b
  89. // b_new = b ^ a_xor_b // Actually a
  90. // a_new = a_xor_b ^ b_new // a_xor_b ^ a // Actually b
  91.  
  92. // c = 10 a = 15 b = 5
  93.         // -> a = 14 b = 6 c = 14/5 == 2 -> c = 3
  94. // c = 3 a = 14 b = 6
  95.             // ->
  96.  
  97. // 3 = 011
  98. // 6 = 110
  99. //     010 == 2
  100.  
  101. // 6 = 0110
  102. // 8 = 1000
  103. //     0000
  104.  
  105. // 3    = 00000011
  106. // 3<<3 = 00011000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement