Record Detail

Compile Error

/in/ex1.c: In function 'main':
/in/ex1.c:10:9: error: conflicting types for 'a'
     int a=0,b=0,c=0,d=0,e=0,flag;
         ^
/in/ex1.c:8:10: note: previous declaration of 'a' was here
     char a[MAX_LENGTH];
          ^
/in/ex1.c:11:14: error: expected ')' before 'flag'
     if ((int flag=strchr(a, ".cpp"))!= NULL){a++;
              ^~~~
/in/ex1.c:11:37: error: expected expression before '!=' token
     if ((int flag=strchr(a, ".cpp"))!= NULL){a++;
                                     ^~
/in/ex1.c:12:25: error: passing argument 1 of 'strchr' makes pointer from integer without a cast [-Werror=int-conversion]
     strcpy(flag, strchr(flag, ".cpp"));}
                         ^~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:225:14: note: expected 'const char *' but argument is of type 'int'
 extern char *strchr (const char *__s, int __c)
              ^~~~~~
/in/ex1.c:12:31: error: passing argument 2 of 'strchr' makes integer from pointer without a cast [-Werror=int-conversion]
     strcpy(flag, strchr(flag, ".cpp"));}
                               ^~~~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:225:14: note: expected 'int' but argument is of type 'char *'
 extern char *strchr (const char *__s, int __c)
              ^~~~~~
/in/ex1.c:12:12: error: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Werror=int-conversion]
     strcpy(flag, strchr(flag, ".cpp"));}
            ^~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:121:14: note: expected 'char * restrict' but argument is of type 'int'
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^~~~~~
/in/ex1.c:13:19: error: expected ')' before 'flag'
     else if ((int flag=strchr(a, ".doc"))!= NULL){b++;
                   ^~~~
/in/ex1.c:13:42: error: expected expression before '!=' token
     else if ((int flag=strchr(a, ".doc"))!= NULL){b++;
                                          ^~
/in/ex1.c:14:29: error: passing argument 1 of 'strchr' makes pointer from integer without a cast [-Werror=int-conversion]
         strcpy(flag, strchr(flag, ".doc"));}
                             ^~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:225:14: note: expected 'const char *' but argument is of type 'int'
 extern char *strchr (const char *__s, int __c)
              ^~~~~~
/in/ex1.c:14:35: error: passing argument 2 of 'strchr' makes integer from pointer without a cast [-Werror=int-conversion]
         strcpy(flag, strchr(flag, ".doc"));}
                                   ^~~~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:225:14: note: expected 'int' but argument is of type 'char *'
 extern char *strchr (const char *__s, int __c)
              ^~~~~~
/in/ex1.c:14:16: error: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Werror=int-conversion]
         strcpy(flag, strchr(flag, ".doc"));}
                ^~~~
In file included from /in/ex1.c:2:0:
/usr/include/string.h:121:14: note: expected 'char * restrict' but argument is of type 'int'
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^~~~~~
/in/ex1.c:10:25: error: unused variable 'e' [-Werror=unused-variable]
     int a=0,b=0,c=0,d=0,e=0,flag;
                         ^
/in/ex1.c:10:21: error: unused variable 'd' [-Werror=unused-variable]
     int a=0,b=0,c=0,d=0,e=0,flag;
                     ^
/in/ex1.c:10:17: error: unused variable 'c' [-Werror=unused-variable]
     int a=0,b=0,c=0,d=0,e=0,flag;
                 ^
cc1: all warnings being treated as errors

Information

Submit By
Type
Submission
Problem
Mid2 Ex1
Homework
Midterm Exam 2
Language
C
Submit At
2022-07-07 15:36:49
Judged At
2022-07-08 16:06:01
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes