Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

about 8 years ago

Language

Compiler

Options

Author

anonymous

about 8 years ago

$
prog.cc: In function 'int main()':
prog.cc:8:30: error: no match for 'operator=' (operand types are 'FILE {aka _IO_FILE}' and 'FILE* {aka _IO_FILE*}')
     f = fopen("plik.txt", "r");
                              ^
In file included from /usr/include/stdio.h:74:0,
                 from prog.cc:1:
/usr/include/libio.h:241:8: note: candidate: 'constexpr _IO_FILE& _IO_FILE::operator=(const _IO_FILE&)'
 struct _IO_FILE {
        ^~~~~~~~
/usr/include/libio.h:241:8: note:   no known conversion for argument 1 from 'FILE* {aka _IO_FILE*}' to 'const _IO_FILE&'
/usr/include/libio.h:241:8: note: candidate: 'constexpr _IO_FILE& _IO_FILE::operator=(_IO_FILE&&)'
/usr/include/libio.h:241:8: note:   no known conversion for argument 1 from 'FILE* {aka _IO_FILE*}' to '_IO_FILE&&'
prog.cc:9:22: error: cannot convert 'FILE {aka _IO_FILE}' to 'FILE* {aka _IO_FILE*}' for argument '1' to 'int fscanf(FILE*, const char*, ...)'
     fscanf(f,"%d", &n);
                      ^
prog.cc:11:11: error: invalid conversion from 'int*' to 'int' [-fpermissive]
     tab = (int *)calloc(n, sizeof(int)); //alokuje sobie pamiec pod tablice
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:12:16: warning: NULL used in arithmetic [-Wpointer-arith]
     if (tab == NULL)
                ^~~~
prog.cc:20:27: error: cannot convert 'FILE {aka _IO_FILE}' to 'FILE* {aka _IO_FILE*}' for argument '1' to 'int fscanf(FILE*, const char*, ...)'
         fscanf(f, "%d", &x);
                           ^
prog.cc:22:14: error: invalid types 'int[int]' for array subscript
         tab[i] = x;
              ^
prog.cc:30:22: error: invalid types 'int[int]' for array subscript
             if (tab[i] > tab[i + 1])
                      ^
prog.cc:30:35: error: invalid types 'int[int]' for array subscript
             if (tab[i] > tab[i + 1])
                                   ^
prog.cc:32:26: error: invalid types 'int[int]' for array subscript
                 z = tab[i];
                          ^
prog.cc:33:22: error: invalid types 'int[int]' for array subscript
                 tab[i] = tab[i + 1];
                      ^
prog.cc:33:35: error: invalid types 'int[int]' for array subscript
                 tab[i] = tab[i + 1];
                                   ^
prog.cc:34:26: error: invalid types 'int[int]' for array subscript
                 tab[i + 1] = z;
                          ^
prog.cc:39:27: error: invalid types 'int[int]' for array subscript
         printf("%d", tab[i]);
                           ^
prog.cc:41:13: error: invalid conversion from 'int' to 'void*' [-fpermissive]
     free(tab); //podczas kompilacji tu mi wyskakuje error.
             ^
In file included from /opt/wandbox/gcc-head/include/c++/8.0.0/cstdlib:75:0,
                 from /opt/wandbox/gcc-head/include/c++/8.0.0/stdlib.h:36,
                 from prog.cc:2:
/usr/include/stdlib.h:483:13: note:   initializing argument 1 of 'void free(void*)'
 extern void free (void *__ptr) __THROW;
             ^~~~
prog.cc:42:13: error: cannot convert 'FILE {aka _IO_FILE}' to 'FILE* {aka _IO_FILE*}' for argument '1' to 'int fclose(FILE*)'
     fclose(f);
             ^
Exit Code:
1