fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. #define SOME_VAL(A) sizeof(A)/sizeof(A[0])
  7. bool is_cmp_value(char *ptr1, char *ptr2)
  8. {
  9. if(ptr2==ptr1)
  10. return true;
  11. else
  12. return false;
  13. }
  14.  
  15. int give_me_val(int *p_buf, unsigned int lgh)
  16. {
  17. unsigned int sum;
  18. for (int i=0;i<lgh;sum+=p_buf[i++]);
  19. return sum;
  20. }
  21.  
  22. int main(void) {
  23. bool is_cmp;
  24. int sum_result;
  25.  
  26. int array1[6];
  27. int array2[6];
  28.  
  29. time_t t;
  30. srand((unsigned) time(&t));
  31.  
  32. for(int i=0;i<6;i++)
  33. {
  34. array1[i] = rand() - RAND_MAX/2;
  35. array2[i] = rand() - RAND_MAX/2;
  36. }
  37.  
  38. is_cmp = is_cmp_value(&array1[0],&array2[0]);
  39. sun_result =give_me_val(&array1[0],SOME_VAL(array1));
  40. return 0;
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:38:24: warning: passing argument 1 of 'is_cmp_value' from incompatible pointer type [-Wincompatible-pointer-types]
  is_cmp = is_cmp_value(&array1[0],&array2[0]);
                        ^
prog.c:7:6: note: expected 'char *' but argument is of type 'int *'
 bool is_cmp_value(char *ptr1, char *ptr2)
      ^
prog.c:38:35: warning: passing argument 2 of 'is_cmp_value' from incompatible pointer type [-Wincompatible-pointer-types]
  is_cmp = is_cmp_value(&array1[0],&array2[0]);
                                   ^
prog.c:7:6: note: expected 'char *' but argument is of type 'int *'
 bool is_cmp_value(char *ptr1, char *ptr2)
      ^
prog.c:39:2: error: 'sun_result' undeclared (first use in this function)
  sun_result =give_me_val(&array1[0],SOME_VAL(array1));
  ^
prog.c:39:2: note: each undeclared identifier is reported only once for each function it appears in
prog.c:24:6: warning: unused variable 'sum_result' [-Wunused-variable]
  int sum_result;
      ^
prog.c:23:7: warning: variable 'is_cmp' set but not used [-Wunused-but-set-variable]
  bool is_cmp;
       ^
stdout
Standard output is empty