foo.c: In function 'bintodec':
foo.c:7:20: error: subscripted value is neither array nor pointer nor vector
7 | while (pbin[ii] != 0) {
| ^
foo.c:8:44: error: subscripted value is neither array nor pointer nor vector
8 | result = result * 2 + (pbin[ii] - '0')
| ^
foo.c:8:55: error: expected ';' before 'ii'
8 | result = result * 2 + (pbin[ii] - '0')
| ^
| ;
9 | ii++;
| ~~
foo.c:4:13: warning: variable 'ii' set but not used [-Wunused-but-set-variable]
4 | int ii = 0;
| ^~
foo.c: In function 'main':
foo.c:21:62: warning: passing argument 1 of 'bintodec' makes integer from pointer without a cast [-Wint-conversion]
21 | printf("%s转换为十进制的结果是:%d\n", str, bintodec(str));
| ^~~
| |
| char *
foo.c:3:26: note: expected 'char' but argument is of type 'char *'
3 | long bintodec(const char pbin) {
| ~~~~~~~~~~~^~~~
foo.c:21:42: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
21 | printf("%s转换为十进制的结果是:%d\n", str, bintodec(str));
| ~^ ~~~~~~~~~~~~~
| | |
| int long int
| %ld
[Hydro](https://hydro.ac)提供评测服务