foo.cc: In function 'int Count(std::string)':
foo.cc:7:18: error: 'i' was not declared in this scope
7 | while(s1[i]!=0){
| ^
foo.cc: In function 'int main()':
foo.cc:15:13: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
15 | gets(s1);
| ~~~~^~~~
In file included from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/cstdio:42,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/ext/string_conversions.h:43,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3968,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/string:53,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/locale_classes.h:40,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/bits/ios_base.h:41,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/ios:42,
from /nix/store/h5kvfrjmpw792v8jg7nrzfkffmn0iyy8-gcc-12.3.0/include/c++/12.3.0/ostream:38,
from iostream:39:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:14: note: declared here
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ^~~~
foo.cc:15:13: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
15 | gets(s1);
| ~~~~^~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:14: note: declared here
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ^~~~
foo.cc:15:14: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
15 | gets(s1);
| ^~
| |
| std::string {aka std::__cxx11::basic_string<char>}
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:26: note: initializing argument 1 of 'char* gets(char*)'
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ~~~~~~^~~
foo.cc:16:13: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
16 | gets(s2);
| ~~~~^~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:14: note: declared here
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ^~~~
foo.cc:16:13: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
16 | gets(s2);
| ~~~~^~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:14: note: declared here
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ^~~~
foo.cc:16:14: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
16 | gets(s2);
| ^~
| |
| std::string {aka std::__cxx11::basic_string<char>}
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/stdio.h:605:26: note: initializing argument 1 of 'char* gets(char*)'
605 | extern char *gets (char *__s) __wur __attribute_deprecated__;
| ~~~~~~^~~
[Hydro](https://hydro.ac)提供评测服务