/ Vijos /

记录详情

Compile Error

foo.c:54:5: error: conflicting types for 'toInt'; have 'int(char)'
   54 | int toInt(char str){
      |     ^~~~~
foo.c:6:5: note: previous declaration of 'toInt' with type 'int(char *)'
    6 | int toInt(char *str);
      |     ^~~~~
foo.c: In function 'toInt':
foo.c:56:14: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast [-Wint-conversion]
   56 | for(i=strlen(str)-1;i>=0;i--){
      |              ^~~
      |              |
      |              char
In file included from foo.c:2:
/nix/store/iczlqwdj10xiz3mmms6adnra0mn3ljk1-glibc-2.35-224-dev/include/string.h:407:35: note: expected 'const char *' but argument is of type 'char'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
foo.c:57:14: error: subscripted value is neither array nor pointer nor vector
   57 | ans+=base(str[i]-'0');
      |              ^
foo.c:57:6: error: called object 'base' is not a function or function pointer
   57 | ans+=base(str[i]-'0');
      |      ^~~~
foo.c:55:7: note: declared here
   55 | int i,base=1,ans=0;
      |       ^~~~
foo.c: In function 'add':
foo.c:64:10: warning: passing argument 1 of 'toInt' makes integer from pointer without a cast [-Wint-conversion]
   64 | if(toInt(delta)>10 || toInt(addTo)>10)
      |          ^~~~~
      |          |
      |          char *
foo.c:54:16: note: expected 'char' but argument is of type 'char *'
   54 | int toInt(char str){
      |           ~~~~~^~~
foo.c:64:29: warning: passing argument 1 of 'toInt' makes integer from pointer without a cast [-Wint-conversion]
   64 | if(toInt(delta)>10 || toInt(addTo)>10)
      |                             ^~~~~
      |                             |
      |                             char *
foo.c:54:16: note: expected 'char' but argument is of type 'char *'
   54 | int toInt(char str){
      |           ~~~~~^~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1300 儿子游戏机
语言
C
递交时间
2023-07-17 11:15:03
评测时间
2023-07-17 11:15:03
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes