Problem sumofdigits
User tanyap2906
Submission Time 2026-08-25 14:29:03
Score 0
Max Time N/A
Max Memory N/A

Compile Error

sumofdigits.cpp: In function ‘int32_t main()’:
sumofdigits.cpp:9:24: error: invalid use of member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ (did you forget the ‘()’ ?)
9 | for (int i = 0; i < a.length; i++){
| ~~^~~~~~
| ()
sumofdigits.cpp:10:19: error: no matching function for call to ‘stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)’
10 | ans += stoi(a[i]);
| ^
In file included from /usr/include/c++/9/string:55,
from /usr/include/c++/9/bits/locale_classes.h:40,
from /usr/include/c++/9/bits/ios_