criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<cctype>
#include<cstdio>
#include<cstring>

int main(){
 while(1){
  char str[1001];
  int n;
  scanf("%s", str);
  if(str=='0') break;
  n=strlen(str);
 
  int sum=0;
  for(int i=0;i<=n;++i){
   sum+=str[i]-'0';
  }
  printf("%d",sum);
 }
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |   if(str=='0') break;
      |      ~~~^~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include<cctype>
using namespace std;

int main()
{
	char str[1001];
	
	while (1) {
		scanf("%s",str);
		int sum = 0;
		if (strcmp(str,'0'==0)) {
			break;
		}
		else {
			for (int i = 0; i < strlen(str); i++) {
				sum += (str[i] - '0');
			}
		}
		printf("%d\n",sum)

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'strcmp' was not declared in this scope
   13 |                 if (strcmp(str,'0'==0)) {
      |                     ^~~~~~
a.cc:4:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cctype>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc:17:45: error: 'strlen' was not declared in this scope
   17 |                         for (int i = 0; i < strlen(str); i++) {
      |                                             ^~~~~~
a.cc:17:45: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:21:35: error: expected ';' before '}' token
   21 |                 printf("%d\n",sum)
      |                                   ^
      |                                   ;
   22 | 
   23 |         }
      |         ~
Language: C++

#include <iostream>
#include <cstdio>
#include<cctype>
#include<csstring>
using namespace std;

int main()
{
	char str[1001];
	
	while (1) {
		scanf("%s",str);
		int sum = 0;
		if (strcmp(str,'0'==0)) {
			break;
		}
		else {
			for (int i = 0; i < strlen(str); i++) {
				sum += (str[i] - '0');
			}
		}
		printf("%d\n",sum)

	}
	return 0;
}

Compiler output:
a.cc:4:9: fatal error: csstring: No such file or directory
    4 | #include<csstring>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
#include<cctype>
#include<cstring>
using namespace std;

int main()
{
	char str[1001];
	
	while (1) {
		scanf("%s",str);
		int sum = 0;
		if (strcmp(str,'0'==0)) {
			break;
		}
		else {
			for (int i = 0; i < strlen(str); i++) {
				sum += (str[i] - '0');
			}
		}
		printf("%d\n",sum)

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:35: error: cannot convert 'bool' to 'const char*'
   14 |                 if (strcmp(str,'0'==0)) {
      |                                ~~~^~~
      |                                   |
      |                                   bool
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:4:
/usr/include/string.h:156:50: note:   initializing argument 2 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                                      ~~~~~~~~~~~~^~~~
a.cc:22:35: error: expected ';' before '}' token
   22 |                 printf("%d\n",sum)
      |                                   ^
      |                                   ;
   23 | 
   24 |         }
      |         ~
Language: C++

#include <iostream>
#include <cstdio>
#include<cctype>
#include<cstring>
using namespace std;

int main()
{
	char str[1001];
	
	while (1) {
		scanf_s("%s",str,1001);
		int sum = 0;
		if (strcmp(str,"0")==0) {
			break;
		}
		else {
			for (int i = 0; i < strlen(str); i++) {
				sum += (str[i] - '0');
			}
		}
		printf("%d\n", sum);

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   12 |                 scanf_s("%s",str,1001);
      |                 ^~~~~~~
      |                 scanf
Language: C++

include<iostream>                                        
#include<cstdio>                                          
#include<cstring>                                         
using namespace std;                                      
                                                          
int main(){                                               
  char number[1001];                                      
  int i;                                                  
  int num;                                                
  while(1){                                               
    scanf("%s",number);                                   
    if(number[0] == '0') break;                           
    int sum = 0;                                          
    for(i=0;i<strlen(number);i++){                        
      num = number[i] - '0';                              
      sum += num;                                         
    }                                                     
    printf("%d\n",sum);                                   
  }                                                       
                                                          
  return 0;                                               
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main() {
	unsighed long x;
	while(cin>>x){
		int sum=0;
		if(x==0) break;
		while(x!=0){
			int n = x%10;
			x = x/10;
			sum+=n;
		}
		cout<<sum<<endl;
		sum=0;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'unsighed' was not declared in this scope; did you mean 'unsigned'?
    6 |         unsighed long x;
      |         ^~~~~~~~
      |         unsigned
a.cc:7:20: error: 'x' was not declared in this scope
    7 |         while(cin>>x){
      |                    ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>

int main()
{
	std::string x;
	int digitsSum;
	while (1)
	{
		std::cin >> x;
		if (!strcmp(x.c_str(), "0"))
		{
			break;
		}
		digitsSum = 0;
		for (int i = 0; i < x.size(); i++)
		{
			digitsSum += x[i] - '0';
		}
		printf("%d\n", digitsSum);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'strcmp' was not declared in this scope
   12 |                 if (!strcmp(x.c_str(), "0"))
      |                      ^~~~~~
a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <stdio.h>
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>

int main()
{
	std::string x;
	int digitsSum;
	while (1)
	{
		std::cin >> x;
		if (!std::strcmp(x.c_str(), "0"))
		{
			break;
		}
		digitsSum = 0;
		for (int i = 0; i < x.size(); i++)
		{
			digitsSum += x[i] - '0';
		}
		printf("%d\n", digitsSum);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:27: error: 'strcmp' is not a member of 'std'
   12 |                 if (!std::strcmp(x.c_str(), "0"))
      |                           ^~~~~~
Language: C++

#include <iostream>
using namespace std;

int main() {
	char num[1000];
	while(1){
		int sum = 0;
		cin >> num;
		if(num == 0)
			break;
		for(int i=0;i < strlen(num);i++){
			sum += num[i] - '0';
		}
		cout << sum << endl;
		for(int i=0;i < strlen(num);i++){
			num[i] = 0;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:33: error: 'strlen' was not declared in this scope
   11 |                 for(int i=0;i < strlen(num);i++){
      |                                 ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:15:33: error: 'strlen' was not declared in this scope
   15 |                 for(int i=0;i < strlen(num);i++){
      |                                 ^~~~~~
a.cc:15:33: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>
 
using namespace std;
 
int main() {
  while (true) {
    int in; cin >> in;
    if (in == "0") break;
    int s = 0;
   while(in != 0){
    s = s + in%10;
    in = in/10;
    }
    cout << s << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |     if (in == "0") break;
      |         ~~~^~~~~~
Language: C++

#include <iostream>
 
using namespace std;
 
int main() {
  while (true) {
    int in; cin >> in;
    if (in == "0") break;
    int s = 0;
   while(in != 0){
    s = s + in%10;
    in = in/10;
    if (in == 0)
       break;
    }
    cout << s << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |     if (in == "0") break;
      |         ~~~^~~~~~
Language: C++

#include<cstdio>
#include<cstring>
int main(){
    char a[1500];
    int s = 1;
   while(true){
        s = 0;
        cin>>s;
        for (int i = 0; i < strlen(a); i++)s = s + a[i] - '0';
        if(s!=0) cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>s;
      |         ^~~
a.cc:10:18: error: 'cout' was not declared in this scope
   10 |         if(s!=0) cout<<s<<endl;
      |                  ^~~~
a.cc:10:27: error: 'endl' was not declared in this scope
   10 |         if(s!=0) cout<<s<<endl;
      |                           ^~~~
Language: C++

#include<cstdio>
#include<cstring>
int main(){
    char a[1500];
    int s = 1;
   while(true){
        s = 0;
        cin>>s;
        for (int i = 0; i < strlen(a); i++)
           s = s + a[i] - '0';
        if(s!=0) cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>s;
      |         ^~~
a.cc:11:18: error: 'cout' was not declared in this scope
   11 |         if(s!=0) cout<<s<<endl;
      |                  ^~~~
a.cc:11:27: error: 'endl' was not declared in this scope
   11 |         if(s!=0) cout<<s<<endl;
      |                           ^~~~
Language: C++

#include<cstdio>
#include<cstring>
int main(){
    char a[1500];
    int s = 1;
   while(true){
        s = 0;
        cin>>s;
        for (int i = 0; i < a.length(); i++)
           s = s + a[i] - '0';
        if(s!=0) 
           cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>s;
      |         ^~~
a.cc:9:31: error: request for member 'length' in 'a', which is of non-class type 'char [1500]'
    9 |         for (int i = 0; i < a.length(); i++)
      |                               ^~~~~~
a.cc:12:12: error: 'cout' was not declared in this scope
   12 |            cout<<s<<endl;
      |            ^~~~
a.cc:12:21: error: 'endl' was not declared in this scope
   12 |            cout<<s<<endl;
      |                     ^~~~
Language: C++

#include<cstdio>
#include<cstring>
int main(){
    char a[1500];
    int s = 1;
   while(true){
        s = 0;
        cin>>s;
        if (s =="0")
            break;
        for (int i = 0; i < a.length(); i++)
           s = s + a[i] - '0';
        if(s!=0) 
           cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>s;
      |         ^~~
a.cc:9:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |         if (s =="0")
      |             ~~^~~~~
a.cc:11:31: error: request for member 'length' in 'a', which is of non-class type 'char [1500]'
   11 |         for (int i = 0; i < a.length(); i++)
      |                               ^~~~~~
a.cc:14:12: error: 'cout' was not declared in this scope
   14 |            cout<<s<<endl;
      |            ^~~~
a.cc:14:21: error: 'endl' was not declared in this scope
   14 |            cout<<s<<endl;
      |                     ^~~~
Language: C++

#include<cstdio>
#include<cstring>
int main(){
    String a[1500];
    int s = 1;
   while(true){
        s = 0;
        cin>>s;
        if (s =="0")
            break;
        for (int i = 0; i < a.length(); i++)
           s = s + a[i] - '0';
        if(s!=0) 
           cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'String' was not declared in this scope
    4 |     String a[1500];
      |     ^~~~~~
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>s;
      |         ^~~
a.cc:9:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |         if (s =="0")
      |             ~~^~~~~
a.cc:11:29: error: 'a' was not declared in this scope
   11 |         for (int i = 0; i < a.length(); i++)
      |                             ^
a.cc:14:12: error: 'cout' was not declared in this scope
   14 |            cout<<s<<endl;
      |            ^~~~
a.cc:14:21: error: 'endl' was not declared in this scope
   14 |            cout<<s<<endl;
      |                     ^~~~
Language: C++

#include <iostream>
  
using namespace std;
  
int main() {
  while (true) {
    int in; cin >> in;
    if (in == 0) break;
    int s = 0;
   while(in != 0){
    s = s + in%10;
    in = in/10;
    if (in == 0)
       break;
    }
    cout << s << endl;
  }
  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: expected '}' at end of input
   18 |   return 0;
      |            ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;
 
void main()
{
    char in[50];
    while (true)
    {
		int s = 0; 
		int i = 0;
        cin >> in;
        if (in[i] == '0')
        {
            break;
        }
        while (in[i])
        {
            s = s + in[i] - '0';
            i++;
        }
        cout << s << endl;
    }
    getchar();
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main()
      | ^~~~
Language: C++


#include <iostream>
using namespace std;
 
void main()
{
    char in[1000];
    while (true)
    {
		int s = 0; 
		int i = 0;
        cin >> in;
        if (in[i] == '0')
        {
            break;
        }
        while (in[i])
        {
            s = s + in[i] - '0';
            i++;
        }
        cout << s << endl;
    }
    getchar();
}

Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	int i;
	int sum;
	while(1) {
		getline(cin, str);
		//cout << str << endl;
		if(str == "0") break;
		sum = 0;
		for(i = 0; i < str.size(); i++) {
			sum += atoi(str[i]);
		}
		cout << sum << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:36: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   17 |                         sum += atoi(str[i]);
      |                                ~~~~^~~~~~~~
      |                                    |
      |                                    __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 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:2:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include <iostream>
int main(){
    int b,c;
    c = 0;
    string number;
    while( scanf("%s",&number)){
     if(number == "0")break;
     for(int a:number){
         b = number[a]-'0';
         c = c + b;
     }
     std::cout << c <<std::endl;
     c = 0;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'string' was not declared in this scope
    5 |     string number;
      |     ^~~~~~
a.cc:5:5: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:6:24: error: 'number' was not declared in this scope
    6 |     while( scanf("%s",&number)){
      |                        ^~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
 int main(){
 	int answerb = 0;
 	string str;
 	cin >> str;
 	for (int i = 0 ; i < str.size(); i++){
 		answer += str[i] - '0';
 	}
 	cout << answer << endl;

 	return 0;
}   

Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'answer' was not declared in this scope; did you mean 'answerb'?
    9 |                 answer += str[i] - '0';
      |                 ^~~~~~
      |                 answerb
a.cc:11:17: error: 'answer' was not declared in this scope; did you mean 'answerb'?
   11 |         cout << answer << endl;
      |                 ^~~~~~
      |                 answerb
Language: C++

#include <iostream>
#include <string>
using namespace std;
 int main(){
 	int answer = 0;
 	string str;
 	cin >> str;
 	for (int i = 0 ; i < str.size(); i++){
 		answer += str[i] - '0';
 		if (answer = 0)break
 	}
 	cout << answer << endl;

 	return 0;
}   

Compiler output:
a.cc: In function 'int main()':
a.cc:10:37: error: expected ';' before '}' token
   10 |                 if (answer = 0)break
      |                                     ^
      |                                     ;
   11 |         }
      |         ~
Language: C++

include<cstdio>
#include<cstring>

int main() {
	char str[1001];

	while (1) {
		scanf("5s,str");
		if (str[0] == '0')break;
		int sum = 0;
		for (int i = 0; i < strlen(str); i++) {
			sum += (str[i] - '0');
		}
		printf("%d\n", sum);
	}
	return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<cstdio>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:17: error: 'scanf' was not declared in this scope
    8 |                 scanf("5s,str");
      |                 ^~~~~
a.cc:14:17: error: 'printf' was not declared in this scope
   14 |                 printf("%d\n", sum);
      |                 ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include<cstring>
  +++ |+#include <cstdio>
    3 |
Language: C++

#include<cstdio>
#include<cstring>

int main() {
	char str[1001];

	while (1) {
		scanf_s("5s,str");
		if (str[0] == '0')break;
		int sum = 0;
		for (int i = 0; i < strlen(str); i++) {
			sum += (str[i] - '0');
		}
		printf("%d\n", sum);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    8 |                 scanf_s("5s,str");
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <stdio.h>
#include <iostream>
#include <ctype.h>
using namespace std;

int calcSumOfNumbers(int x);

int main(void)
{	
	while (1) {
		long int x;
		cin >> x;
		
		if (x == 0) break;
	
		cout << calcSumOfNumbers(x) << endl;
	}
	
	return 0;
}

int calcSumOfNumbers(long int x)
{
	int sum = 0;
	do {
		sum += x % 10;
		x /= 10;
	} while (x);
	
	return sum;
}

Compiler output:
/usr/bin/ld: /tmp/cceQVbcD.o: in function `main':
a.cc:(.text+0x35): undefined reference to `calcSumOfNumbers(int)'
collect2: error: ld returned 1 exit status
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

inline int calcSumOfNumbers(long int x);

int main(void)
{	
	while (1) {
		int x;
		cin >> x;
		
		if (x == 0) break;
	
		cout << calcSumOfNumbers(x) << endl;
	}
	
	return 0;
}

inline int calcSumOfNumbers(int x)
{
	int sum = 0;
	do {
		sum += x % 10;
		x /= 10;
	} while (x);
	
	return sum;
}

Compiler output:
a.cc:5:12: warning: inline function 'int calcSumOfNumbers(long int)' used but never defined
    5 | inline int calcSumOfNumbers(long int x);
      |            ^~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccTbnvjM.o: in function `main':
a.cc:(.text+0x35): undefined reference to `calcSumOfNumbers(long)'
collect2: error: ld returned 1 exit status
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

int calcSumOfNumbers(const char x[]);

int main(void)
{	
	while (1) {
		char x[1000] = "\0";
		cin >> x;
		
		if (x[0] == '0') break;
		
		cout << calcSumOfNumbers(x) << endl;
	}
	
	return 0;
}

int calcSumOfNumbers(const char x[])
{
	int sum = 0;
	for (int i = 0; x[i] != '\0') {
		sum += x[i] - '0';
	}
	
	return sum;
}

Compiler output:
a.cc: In function 'int calcSumOfNumbers(const char*)':
a.cc:24:37: error: expected ';' before ')' token
   24 |         for (int i = 0; x[i] != '\0') {
      |                                     ^
      |                                     ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
char a[1001];
while(1){
scanf("%s", a);
if( a[0] == '0' ) break;
int sum = 0;
for (int i = 0; i < strlen(a); i++ ){
sum += (a[i]-'0');
}
printf("%d\n, sum);
}
return 0;
}

Compiler output:
a.cc:12:8: warning: missing terminating " character
   12 | printf("%d\n, sum);
      |        ^
a.cc:12:8: error: missing terminating " character
   12 | printf("%d\n, sum);
      |        ^~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:13:1: error: expected primary-expression before '}' token
   13 | }
      | ^
Language: C++

#include <iostream>
using namespace std;

int main(){[
 int x,a,b,c,d;
 while(1){
  cin >> x;
  if(x==0)break;
  a=x/1000;
  b=x/100-a*10;
  c=x/10-a*100-b*10;
  d=x%10;
  cout << a+b+c+d << endl;
 }
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:2: error: expected identifier before 'int'
    5 |  int x,a,b,c,d;
      |  ^~~
a.cc:5:7: error: expected ']' before ',' token
    5 |  int x,a,b,c,d;
      |       ^
      |       ]
a.cc: In lambda function:
a.cc:5:7: error: expected '{' before ',' token
a.cc: In function 'int main()':
a.cc:5:8: error: 'a' was not declared in this scope
    5 |  int x,a,b,c,d;
      |        ^
a.cc:5:10: error: 'b' was not declared in this scope
    5 |  int x,a,b,c,d;
      |          ^
a.cc:5:12: error: 'c' was not declared in this scope
    5 |  int x,a,b,c,d;
      |            ^
a.cc:5:14: error: 'd' was not declared in this scope
    5 |  int x,a,b,c,d;
      |              ^
a.cc:7:10: error: 'x' was not declared in this scope
    7 |   cin >> x;
      |          ^
Language: C++

#include <iostream>
using namespace std;

int main(){[
 int sum;
 string x;
 while(1){
  cin >> x;
  if(x=="0")break;
  sum=0;
  for(int i=0;i<x.size();i++){
   sum+=x[i]-'0';
  }
  cout << sum << endl;
 }
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:2: error: expected identifier before 'int'
    5 |  int sum;
      |  ^~~
a.cc:5:9: error: expected ']' before ';' token
    5 |  int sum;
      |         ^
      |         ]
a.cc: In lambda function:
a.cc:5:9: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:10:3: error: 'sum' was not declared in this scope
   10 |   sum=0;
      |   ^~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main(){[
 int sum;
 string x;
 while(1){
  cin >> x;
  if(x=="0")break;
  sum=0;
  for(int i=0;i<x.size();i++){
   sum+=x[i]-'0';
  }
  cout << sum << endl;
 }
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:2: error: expected identifier before 'int'
    6 |  int sum;
      |  ^~~
a.cc:6:9: error: expected ']' before ';' token
    6 |  int sum;
      |         ^
      |         ]
a.cc: In lambda function:
a.cc:6:9: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:11:3: error: 'sum' was not declared in this scope
   11 |   sum=0;
      |   ^~~
Language: C++

#include <stdio.h>
int main(){
char x[1001];
int temp,now;
for(int i=0;i<1001;i++)
x[i]='\0';
while(1){
scanf("%s"x);
if(x[0]==0)return 0;
temp=now=0;
while(x[now]!='\0'){
temp+=x[now]-'0';
now++;
}
for(int i=0;i<now;i++)
x[i]='\0';
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: unable to find string literal operator 'operator""x' with 'const char [3]', 'long unsigned int' arguments
    8 | scanf("%s"x);
      |       ^~~~~
Language: C++

#include<iostream>
using namespace std;

int main(){

	int x, s=0;

	while (1) {
		cin >> x;
		if (x == 0) break;


		for (x >0) {
			s+=x%10;
			x/=10;
		}

		cout << s << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: expected ';' before ')' token
   13 |                 for (x >0) {
      |                          ^
      |                          ;
a.cc:19:9: error: expected primary-expression before '}' token
   19 |         }
      |         ^
a.cc:18:35: error: expected ')' before '}' token
   18 |                 cout << s << endl;
      |                                   ^
      |                                   )
   19 |         }
      |         ~                          
a.cc:13:21: note: to match this '('
   13 |                 for (x >0) {
      |                     ^
a.cc:19:9: error: expected primary-expression before '}' token
   19 |         }
      |         ^
Language: C++

#include<iostream>
using namespace std;

int main(){

	int x, s=0;

	while (1) {
		cin >> x;
		if (x == 0) break;


		for (x > 0;) {
			s+=x%10;
			x/=10;
		}

		cout << s << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:28: error: expected primary-expression before ')' token
   13 |                 for (x > 0;) {
      |                            ^
a.cc:13:28: error: expected ';' before ')' token
   13 |                 for (x > 0;) {
      |                            ^
      |                            ;
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

int main() {
  std::string str;

  while(1) {
    std::cin >> str;
    int sum = 0;
    for(int i = 0; str[i] != '\0'; ++i) {
      char c = str[i];
      sum += std::atoi(&c);
    }
    if(sum == 0) break
    std::cout << sum << std::endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: expected ';' before 'std'
   16 |     if(sum == 0) break
      |                       ^
      |                       ;
   17 |     std::cout << sum << std::endl;
      |     ~~~
Language: C++

#include <iostream>
#include <iomanip>
using namespace std;
int main(){
   double int x;
     int ans=0;
    while(cin>>x && x!=0){
        while(x!=0){
        ans+=x%10;
        x=x/10;
            if(x==0){
            cout<<ans<<endl;
            ans=0;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:4: error: two or more data types in declaration of 'x'
    5 |    double int x;
      |    ^~~~~~
a.cc:7:16: error: 'x' was not declared in this scope
    7 |     while(cin>>x && x!=0){
      |                ^
Language: C++

#include <iostream>
using namespace std;
int main(){

string a;
cin>>a;

int x[1000];
int sum=0;
for(int i=0;i<a.size();i){
x[i]=a[i];
sum+=a[i];
}
cout<<sum<,endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: expected primary-expression before ',' token
   14 | cout<<sum<,endl;
      |           ^
Language: C++

#include <iostream>
#include <string>

int main()
{
	std::string s;
	for (;;) {
		std::cin >> s;
		if (!s) break;
		int sum {}
		for (int i=0; s[i]; ++i)
			sum += s[i] - '0';
		std::cout << sum << '\n';
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: no match for 'operator!' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'})
    9 |                 if (!s) break;
      |                     ^~
a.cc:9:21: note: candidate: 'operator!(bool)' (built-in)
a.cc:9:21: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'bool'
a.cc:11:17: error: expected ',' or ';' before 'for'
   11 |                 for (int i=0; s[i]; ++i)
      |                 ^~~
a.cc:11:33: error: 'i' was not declared in this scope
   11 |                 for (int i=0; s[i]; ++i)
      |                                 ^
Language: C++

#include <iostream>
#include <string>

int main()
{
	std::string s;
	for (;;) {
		std::cin >> s;
		if (s[0] == '0') break;
		int sum {}
		for (int i=0; s[i]; ++i)
			sum += s[i] - '0';
		std::cout << sum << '\n';
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: expected ',' or ';' before 'for'
   11 |                 for (int i=0; s[i]; ++i)
      |                 ^~~
a.cc:11:33: error: 'i' was not declared in this scope
   11 |                 for (int i=0; s[i]; ++i)
      |                                 ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
	char str[1000] = { 0 };

	cin.getline(str, 1000);

	while (str[0] != '0') {
		int n = 0;

		for (unsigned int i = 0; i < strlen(str); i++) 
			n += str[i] - '0';

		cout << n << endl;

		cin.getline(str, 1000);
	}

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:46: error: 'strlen' was not declared in this scope
   13 |                 for (unsigned int i = 0; i < strlen(str); i++)
      |                                              ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main()
{
	char str[1000] = { 0 };

	cin.getline(str, 1000);

	while (str[0] != '0') {
		int n = 0;

		for (unsigned int i = 0; i < strlen(str); i++) 
			n += str[i] - '0';

		cout << n << endl;

		cin.getline(str, 1000);
	}

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:46: error: 'strlen' was not declared in this scope
   14 |                 for (unsigned int i = 0; i < strlen(str); i++)
      |                                              ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main()
{
	char str[1001] = { 0 };

	cin.getline(str, 1000);

	while (str[0] != '0') {
		int n = 0;

		for (unsigned int i = 0; i < strlen(str); i++) 
			n += str[i] - '0';

		cout << n << endl;

		cin.getline(str, 1000);
	}

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:46: error: 'strlen' was not declared in this scope
   14 |                 for (unsigned int i = 0; i < strlen(str); i++)
      |                                              ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include<algorithm>
#include<cctype>
#include<sstream>

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += array[i];
	}
	return sum;
}

int main(){
	string str;
	int n;
	int sum = 0;
	cin >> n;
	str = to_string(n);
	for (int i = 0; i < str.length(); i++) {
		istringstream in(str[i]);
		int num;
		in >> num;
		sum += num;
	}
	cout << sum;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:40: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::ios_base::openmode' [-fpermissive]
   29 |                 istringstream in(str[i]);
      |                                        ^
      |                                        |
      |                                        __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/bits/quoted_string.h:38,
                 from /usr/include/c++/14/iomanip:50,
                 from a.cc:3:
/usr/include/c++/14/sstream:597:46: note:   initializing argument 1 of 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Alloc>::basic_istringstream(std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::ios_base::openmode = std::ios_base::openmode]'
  597 |       basic_istringstream(ios_base::openmode __mode)
      |                           ~~~~~~~~~~~~~~~~~~~^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include<algorithm>
#include<cctype>
#include<sstream>

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += array[i];
	}
	return sum;
}

int main(){
	char str[1001];
	while (1) {
		cin >> str;
		int sum = 0;
		if (str == "0") break;
		else {
			for (int i = 0; i < strlen(str);i++) {
				sum += str[i] - '0';
			}
		}
		cout << sum;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:45: error: 'strlen' was not declared in this scope
   29 |                         for (int i = 0; i < strlen(str);i++) {
      |                                             ^~~~~~
a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<cctype>
  +++ |+#include <cstring>
    7 | #include<sstream>
Language: C++

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include<algorithm>
#include<cctype>
#include<sstream>
#include<string.h>

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += array[i];
	}
	return sum;
}

int main(){
	char str[1001];
	for(int k=o;k<100;k++){
		cin >> str;
		int sum = 0;
			for (int i = 0; i < sizeof(str);i++) {
				sum += (str[i] - '0');
			}
			if (sum==0)
			{
				break;
			}
		cout << sum;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:19: error: 'o' was not declared in this scope
   25 |         for(int k=o;k<100;k++){
      |                   ^
Language: C++

#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

int main(){
	int a;
	string num;
	while (1){
		a = 0;
		cin >> num;
		if (num == "0")break;
		
		for (int i = 0; i < num.size; i++){
			a = num[i]-'0';
			a += num[i];
		}
		cout << a << endl;
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:41: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   14 |                 for (int i = 0; i < num.size; i++){
      |                                     ~~~~^~~~
      |                                             ()
Language: C++

#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

int main ()
{
  int count = 0;
  int sum;
  vector<int> x(100);

  while (1) {
    scanf("%d", &x[count]);
    if (x[count] == 0) {
      break;
    }
    count++;
  }

  for (int i = 0; i < count; i++) {
    sum = 0;
    while (count[i] > 0) {
      sum += count[i] % 10;
      count[i] /= 10;
    }
    printf("%d\n", sum);
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: invalid types 'int[int]' for array subscript
   23 |     while (count[i] > 0) {
      |                 ^
a.cc:24:19: error: invalid types 'int[int]' for array subscript
   24 |       sum += count[i] % 10;
      |                   ^
a.cc:25:12: error: invalid types 'int[int]' for array subscript
   25 |       count[i] /= 10;
      |            ^
Language: C++

#include<stdio.h>
#include<string>

int main() {
	char x[1024];
	int datas[BUFSIZ];

	for (int i = 0; i < BUFSIZ;i++) {
		//in
		fflush(stdin);
		scanf("%s", x);

		datas[i] = 0;

		if (x[0] == '0') 	break;
		
		//initialize
		int len = strlen(x);

		//sum
		for (int j = 0; j < len; j++) {
			int temp = x[j] - '0';
			datas[i] += temp;
		}

	}
	
	for (int i = 0; i < BUFSIZ && datas[i]; i++) {
		printf("%d\n", datas[i]);
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:27: error: 'strlen' was not declared in this scope
   18 |                 int len = strlen(x);
      |                           ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<string>
  +++ |+#include <cstring>
    3 |
Language: C++

#include<stdio.h>
#include<string>

int main() {
	char x[1024];
	int datas[BUFSIZ];

	for (int i = 0; i < BUFSIZ;i++) {
		//in
		fflush(stdin);
		scanf("%s", x);

		datas[i] = 0;

		if (x[0] == '0') 	break;
		
		//initialize
		int len;
		len = strlen(x);

		//sum
		for (int j = 0; j < len; j++) {
			int temp = x[j] - '0';
			datas[i] += temp;
		}

	}
	
	for (int i = 0; i < BUFSIZ && datas[i]; i++) {
		printf("%d\n", datas[i]);
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:23: error: 'strlen' was not declared in this scope
   19 |                 len = strlen(x);
      |                       ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<string>
  +++ |+#include <cstring>
    3 |
Language: C++

#include<iostream>
#include<string>
#include<typeinfo>
#include<stdilb.h>
using namespace std;

int main(){
	string str;
	int sum,num1=0,num2=0,num3=0,num4=0;
	while(1){
		cin>>str;
		if(str=="0")break;
		else{
			sum=atoi(str.c_str());
			num1=sum/1000;
			num2=(sum-num1*1000)/100;
			num3=(sum-num1*1000-num2*100)/10;
			num4=(sum-num1*1000-num2*100-num3*10);
			sum=num1+num2+num3+num4;
			cout<<sum<<endl;
		}
	}
}



Compiler output:
a.cc:4:9: fatal error: stdilb.h: No such file or directory
    4 | #include<stdilb.h>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
#include<typeinfo>
#include<cstdilb>
using namespace std;

int main(){
	string str;
	int sum,num1=0,num2=0,num3=0,num4=0;
	while(1){
		cin>>str;
		if(str=="0")break;
		else{
			sum=atoi(str.c_str());
			num1=sum/1000;
			num2=(sum-num1*1000)/100;
			num3=(sum-num1*1000-num2*100)/10;
			num4=(sum-num1*1000-num2*100-num3*10);
			sum=num1+num2+num3+num4;
			cout<<sum<<endl;
		}
	}
}



Compiler output:
a.cc:4:9: fatal error: cstdilb: No such file or directory
    4 | #include<cstdilb>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

int main(){
  string str;
  int sum;
  while(cin >> str && str!="0"){
    sum = 0;
    for(int i=0,l=str.size();i<l;i++) sum += str[i]-'0';
    cout << sum << endl;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:2:3: error: 'string' was not declared in this scope
    2 |   string str;
      |   ^~~~~~
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |   while(cin >> str && str!="0"){
      |         ^~~
a.cc:4:16: error: 'str' was not declared in this scope; did you mean 'std'?
    4 |   while(cin >> str && str!="0"){
      |                ^~~
      |                std
a.cc:7:5: error: 'cout' was not declared in this scope
    7 |     cout << sum << endl;
      |     ^~~~
a.cc:7:20: error: 'endl' was not declared in this scope
    7 |     cout << sum << endl;
      |                    ^~~~
Language: C++

<?php
$display = array();
while (true) {
  $received_num = str_split(trim(fgets(STDIN)));
  if ($received_num[0] == 0) {
    break;
  }
  $sum = array_sum($received_num);
  array_push($display, $sum);
}
echo implode("\n", $display);


Compiler output:
a.cc:1:1: error: expected unqualified-id before '<' token
    1 | <?php
      | ^
a.cc:3:1: error: expected unqualified-id before 'while'
    3 | while (true) {
      | ^~~~~
a.cc:11:1: error: 'echo' does not name a type
   11 | echo implode("\n", $display);
      | ^~~~
Language: C++

#include <stdio.h>
#include <string.h>
#define rep(i, a) for(int i = 0; i < a; ++i)

int main(void) {
  char s[1500];
  int i, ans = 0;
  while( 1 ) {
  ans = 0;
  scanf("%s", s);
  if(strlen(s) = 1 && s[0] == 0) break;
  rep(i, strlen(s)) ans += s[i] - '0';
  printf("%d\n", ans);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: lvalue required as left operand of assignment
   11 |   if(strlen(s) = 1 && s[0] == 0) break;
      |      ~~~~~~^~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

const int dataset_MAX = 1200,num_MAX=1001;
int sum[dataset_MAX];


int main(){
	int dataset = 0;
	for (;;dataset++){
		char num[num_MAX];
		sum[dataset] = 0;
		scanf("%s", num,num_MAX);
		//cin >> num;
		int i = 0;
		for (;i<(unsigned int)strlen(num); i++){
			sum[dataset] += num[i] - '0';
		}
		scanf("%*c");
		if (num[0] == '0')break;
	}
	for (int i = 0; i < dataset; i++){
		cout << sum[i] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:39: error: 'strlen' was not declared in this scope
   18 |                 for (;i<(unsigned int)strlen(num); i++){
      |                                       ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cctype>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

const int dataset_MAX = 1200,num_MAX=1001;
int sum[dataset_MAX];


int main(){
	int dataset = 0;
	for (;;dataset++){
		char num[num_MAX];
		sum[dataset] = 0;
		scanf_s("%s", num,num_MAX);
		int i = 0;
		for (;i<(unsigned int)strlen(num); i++){
			sum[dataset] += num[i] - '0';
		}
		scanf_s("%*c");
		if (num[0] == '0')break;
	}
	for (int i = 0; i < dataset; i++){
		cout << sum[i] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |                 scanf_s("%s", num,num_MAX);
      |                 ^~~~~~~
      |                 scanf
a.cc:17:39: error: 'strlen' was not declared in this scope
   17 |                 for (;i<(unsigned int)strlen(num); i++){
      |                                       ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cctype>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

const int dataset_MAX = 1200,num_MAX=1001;
int sum[dataset_MAX];


int main(){
	int dataset = 0;
	for (;;dataset++){
		char num[num_MAX];
		sum[dataset] = 0;
		cin >> num;
		int i = 0;
		for (;i<(unsigned int)strlen(num); i++){
			sum[dataset] += num[i] - '0';
		}
		if (num[0] == '0')break;
	}
	for (int i = 0; i < dataset; i++){
		cout << sum[i] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:39: error: 'strlen' was not declared in this scope
   17 |                 for (;i<(unsigned int)strlen(num); i++){
      |                                       ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cctype>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main(){
  string number[1001];

  while(1){
    int sum = 0;
    scanf("%s", number);
    if(number[0] == "0") break;
    for (int i=0; i<strlen(number); i++){
      sum += (number[i] - "0");
    }
  }

  printf("%d\n", sum);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: 'strlen' was not declared in this scope
   12 |     for (int i=0; i<strlen(number); i++){
      |                     ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
a.cc:13:25: error: no match for 'operator-' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'const char [2]')
   13 |       sum += (number[i] - "0");
      |               ~~~~~~~~~ ^ ~~~
      |                       |   |
      |                       |   const char [2]
      |                       std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/string:48,
                 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/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:13:27: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   13 |       sum += (number[i] - "0");
      |                           ^~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:13:27: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
   13 |       sum += (number[i] - "0");
      |                           ^~~
a.cc:17:18: error: 'sum' was not declared in this scope
   17 |   printf("%d\n", sum);
      |                  ^~~
Language: C++

#include <cstdio>
#include <cstring>


int main()
{
	int sum;
	char str[1000];

	while (true)
	{
		scanf_s("%s", str);

		if (str[0] == '0') {
			break;
		}

		sum = 0;
		for (int i = 0;i < strlen(str);i++) {
			sum += str[i] - '0';
		}

		printf("%d\n", sum);

	}

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   12 |                 scanf_s("%s", str);
      |                 ^~~~~~~
      |                 scanf