fork download
  1. #include <stdio.h>
  2. #define MAX 10
  3.  
  4. int* getIntegers() {
  5. int a[MAX];
  6. int i = 0;
  7. while (i < MAX) {
  8. int n;
  9. printf("Insert an integer: ");
  10. scanf("%d", &n);
  11. a[i] = n;
  12. i++;
  13. }
  14. int *p = a;
  15. return p;
  16. }
  17.  
  18. int findMax(int *s) {
  19. int max = -1000000;
  20. for (int i = 0; i < MAX; i++) {
  21. if (s[i] > max) {
  22. max = s[i];
  23. }
  24. }
  25. return max;
  26. }
  27.  
  28. int main() {
  29. int *p = getTenIntegers();
  30. int max = findMax(p);
  31. printf("Max value: %d\n", max);
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:29:12: warning: implicit declaration of function ‘getTenIntegers’ [-Wimplicit-function-declaration]
   int *p = getTenIntegers();
            ^~~~~~~~~~~~~~
prog.c:29:12: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
prog.c: In function ‘getIntegers’:
prog.c:15:10: warning: function returns address of local variable [-Wreturn-local-addr]
   return p;
          ^
prog.c:5:7: note: declared here
   int a[MAX];
       ^
/home/sUZKlk/cc7yNMqM.o: In function `main':
prog.c:(.text.startup+0x7): undefined reference to `getTenIntegers'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty