Language: C++

#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
    
    
    
    while(1) {
        
        char num[1001];
        
        cin >> num;
        
        if (num[0] == '0') break;
        
        int sum;
        
        int count = to_string(num).length();
        
        for (int i = 0; i < count; i ++) {
            
            sum += num[i] - '0';
            
        }
        
        cout << sum << endl;
        
        
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:30: error: no matching function for call to 'to_string(char [1001])'
   18 |         int count = to_string(num).length();
      |                     ~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)' (near match)
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4240:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)' (near match)
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'unsigned int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)' (near match)
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'long int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)' (near match)
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'long unsigned int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)' (near match)
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'long long int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)' (near match)
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note:   conversion of argument 1 would be ill-formed:
a.cc:18:31: error: invalid conversion from 'char*' to 'long long unsigned int' [-fpermissive]
   18 |         int count = to_string(num).length();
      |                               ^~~
      |                               |
      |                               char*
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:19: note:   no known conversion for argument 1 from 'char [1001]' to 'float'
 4401 |   to_string(float __val)
      |             ~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:20: note:   no known conversion for argument 1 from 'char [1001]' to 'double'
 4411 |   to_string(double __val)
      |             ~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:25: note:   no known conversion for argument 1 from 'char [1001]' to 'long double'
 4421 |   to_string(long double __val)
      |             ~~~~~~~~~~~~^~~~~