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

#include <stdio.h>
#define int long long

int main()
{
    int x
    int sum;
    scanf("%d", &x);
    while(x != 0) {
      sum=0;
      while(x != 0) {
          sum += x%10;
          x = x/10;
      }
      printf("%d\n", sum);
      scanf("%d", &x);
    }

    return 0;
}



Compiler output:
main.c: In function 'main':
main.c:6:10: error: expected ';' before 'long'
    6 |     int x
      |          ^
      |          ;
main.c:8:18: error: 'x' undeclared (first use in this function)
    8 |     scanf("%d", &x);
      |                  ^
main.c:8:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

int main()
{
    long x
    int sum;
    scanf("%d", &x);
    while(x != 0) {
      sum=0;
      while(x != 0) {
          sum += x%10;
          x = x/10;
      }
      printf("%d\n", sum);
      scanf("%d", &x);
    }

    return 0;
}



Compiler output:
main.c: In function 'main':
main.c:5:11: error: expected ';' before 'int'
    5 |     long x
      |           ^
      |           ;
    6 |     int sum;
      |     ~~~    
main.c:7:18: error: 'x' undeclared (first use in this function)
    7 |     scanf("%d", &x);
      |                  ^
main.c:7:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	char buf[1250];
	char *p;
	int s;

	while (1) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		s = 0;
		while (isdigit(*p)) s += *p++ - '0';
		if (s == 0) break;
		printf("%d\n", s);
	}
	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:12:17: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   12 |                 gets(buf);
      |                 ^~~~
      |                 fgets
Language: C

#include <stdio.h>
int main(void){
    int x,sum=0;
    while(scanf("%d",&x) != EOF || x=0){
    while(x>10){
        sum += x%10;
        x = x/10;
    
    }
    sum = sum+x;
    printf("%d\n",sum);
    }
}



Compiler output:
main.c: In function 'main':
main.c:4:37: error: lvalue required as left operand of assignment
    4 |     while(scanf("%d",&x) != EOF || x=0){
      |                                     ^
Language: C

#include <stdio.h>
#include <ctype.h>

int main(void)
{
int i,sum[26];
char ABC;
scanf("%c",&ABC);
while(ABC != EOF)

/*EOF(ファイル終了[End Of File])でないかどうか確認*/

{
if (isalpha(ABC) != 0)

/*入力されたものがアルファベットかどうか確認*/

{
sum[(tolower(ABC) -'a')] += 1;

/*入力されたアルファベットを小文字に変換&0~25の数値に変換*/

}
scanf("%c",&ABC);
}
for(i = 0;i <= 25;i++)
{
printf("%c : %d\n",'a' + i,sum[i]);
}
return 0;
}




}


Compiler output:
main.c:36:1: error: expected identifier or '(' before '}' token
   36 | }
      | ^
Language: C

#include<stdio.h>
int main(void){
	int x,sum=0;
	while(scanf("%d",&x) != EOF || x =! 0){
	while(scanf(x>=10){
		sum += x%10;
		x = x/10
		}
	sum = sum+x;
	printf("%d\n",sum);
	}
}


Compiler output:
main.c: In function 'main':
main.c:4:42: error: lvalue required as left operand of assignment
    4 |         while(scanf("%d",&x) != EOF || x =! 0){
      |                                          ^
main.c:5:22: error: passing argument 1 of 'scanf' makes pointer from integer without a cast [-Wint-conversion]
    5 |         while(scanf(x>=10){
      |                     ~^~~~
      |                      |
      |                      int
In file included from main.c:1:
/usr/include/stdio.h:428:42: note: expected 'const char *' but argument is of type 'int'
  428 | extern int scanf (const char *__restrict __format, ...) __wur;
      |                   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:5:27: error: expected ')' before '{' token
    5 |         while(scanf(x>=10){
      |              ~            ^
      |                           )
main.c:11:9: error: expected expression before '}' token
   11 |         }
      |         ^
Language: C

#include<stdio.h>
int main(void)
{
int b,c,d,e,f;
scanf("%d",&b);
0<=c&&c<=9;
0<=d&&d<=9;
0<=e&&e<=9;
0<=f&&f<=9;
1000c+100d+10e+f=b;
printf("%d",c+d+e+f);
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:10:1: error: invalid suffix "c" on integer constant
   10 | 1000c+100d+10e+f=b;
      | ^~~~~
main.c:10:7: error: invalid suffix "d" on integer constant
   10 | 1000c+100d+10e+f=b;
      |       ^~~~
main.c:10:12: error: exponent has no digits
   10 | 1000c+100d+10e+f=b;
      |            ^~~~~
Language: C


#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	char buf[1250];
	char *p;
	int s;

	while (1) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		s = 0;
		while (isdigit(*p)) s += *p++ - '0';
		if (s == 0) break;
		printf("%d\n", s);
	}
	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:13:17: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   13 |                 gets(buf);
      |                 ^~~~
      |                 fgets
Language: C


#include <stdio.h>
int main()
{
	char buf[1250];
	char *p;
	int s;

	while (1) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		s = 0;
		while (isdigit(*p)) s += *p++ - '0';
		if (s == 0) break;
		printf("%d\n", s);
	}
	return 0;
}






  

 



Compiler output:
main.c: In function 'main':
main.c:10:17: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   10 |                 gets(buf);
      |                 ^~~~
      |                 fgets
main.c:12:24: error: implicit declaration of function 'isspace' [-Wimplicit-function-declaration]
   12 |                 while (isspace(*p)) p++;
      |                        ^~~~~~~
main.c:3:1: note: include '<ctype.h>' or provide a declaration of 'isspace'
    2 | #include <stdio.h>
  +++ |+#include <ctype.h>
    3 | int main()
main.c:14:24: error: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
   14 |                 while (isdigit(*p)) s += *p++ - '0';
      |                        ^~~~~~~
main.c:14:24: note: include '<ctype.h>' or provide a declaration of 'isdigit'
Language: C


#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	char buf[1250];
	char *p;
	int s;

	while (1) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		s = 0;
		while (isdigit(*p)) s += *p++ - '0';
		if (s == 0) break;
		printf("%d\n", s);
	}
	return 0;
}



  

 



Compiler output:
main.c: In function 'main':
main.c:13:17: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   13 |                 gets(buf);
      |                 ^~~~
      |                 fgets
Language: C

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

int main(void)
{
	string n;
	int s;

	while (true){
		getline(cin, n);
		if (n == "0") break;
		s = 0;
		for (int i=0; i<n.size(); i++){
			s += (n.at(i)-'0');
		}
		cout << s <<endl;
	}
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
int main(void)
{
  int num;
  while(1){
    int a,b,c,d;
    char a[];
    scanf("%d",&num);
    if (num==0) break;
    else{
      a=num/1000;
      b=num/100-10*a;
      c=num/10-10*b-100*a;
      d=num-10*c-100*b-1000*a;
      printf("%d",a+b+c+d);
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:10: error: conflicting types for 'a'; have 'char[]'
    7 |     char a[];
      |          ^
main.c:6:9: note: previous declaration of 'a' with type 'int'
    6 |     int a,b,c,d;
      |         ^
Language: C

import java.io.IOException;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		int sum=0;
		while(!a.equals("0")){
			int digit = a.length();
			System.out.println(digit);
			for(int i=0;i<digit;i++){
				sum+=a.charAt(i)-'0';
			}
			System.out.println(sum);
			sum=0;
			a=scan.next();
		}
	}

}

Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.io.IOException;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.io.IOException;
      |            ^
main.c:2:1: error: unknown type name 'import'
    2 | import java.util.Scanner;
      | ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | import java.util.Scanner;
      |            ^
main.c:3:1: error: unknown type name 'public'
    3 | public class Main{
      | ^~~~~~
main.c:3:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
    3 | public class Main{
      |              ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int ctoi(char ch)
{
	if ('0' <= ch && ch <= '9')
	{
		return ch - '0';
	}
	else
	{
		return 0;
	}
}

int main()
{
	string x_s;
	vector<int> sum_digits(1001, 0);
	int digit_i;
	int n = 0;
	while (cin >> x_s, x_s != "0")
	{
		for (int i = 0; i < x_s.length(); i++)
		{
			digit_i = ctoi(x_s[i]);
			sum_digits[n] += digit_i;
		}
		n++;
	}
	n = 0;
	while (sum_digits[n] != 0)
	{
		if (sum_digits[n] < 0)
		{
			sum_digits[n] *= -1;
		}
		cout << sum_digits[n++] << endl;
	}



Compiler output:
a.cc: In function 'int main()':
a.cc:42:10: error: expected '}' at end of input
   42 |         }
      |          ^
a.cc:20:1: note: to match this '{'
   20 | {
      | ^
Language: C++

int main(){
    int sum = 0;
    char ch;
 
    while(true)
    {
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0)
            break;
        else{
            printf("%d\n",sum);
            sum = 0;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:21: error: 'getchar' was not declared in this scope
    7 |         while((ch = getchar()) != '\n'){
      |                     ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(){
a.cc:13:13: error: 'printf' was not declared in this scope
   13 |             printf("%d\n",sum);
      |             ^~~~~~
a.cc:13:13: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include"stdafx.h"
#include<cstdio>
#include<cstring>
#pragma warning(disable : 4996)

int main()
{
	char str[1001];

	while (1) {
		scanf("%s", 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:9: fatal error: stdafx.h: No such file or directory
    1 | #include"stdafx.h"
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;

int main(){
    int n[4], sum = 0;
    
    for(int i = 0; i < 4; i++){
        cin >> n[i];
        sum += n[i];
        
        if(c[0] == 0) break;
    }
    cout << sum << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'c' was not declared in this scope
   11 |         if(c[0] == 0) break;
      |            ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
   16 |     num = 0;
      |           ^
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:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  817 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  828 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  840 |       operator=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  858 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
   16 |     num = 0;
      |           ^
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:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  817 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  828 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  840 |       operator=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  858 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
Language: C++

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

int main() {
    string s;
    while(cin >> s, s != "0") {
        cout << accumlate(s.begin(), s.end(), 0) - 48 * s.size() << endl;;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'accumlate' was not declared in this scope
    9 |         cout << accumlate(s.begin(), s.end(), 0) - 48 * s.size() << endl;;
      |                 ^~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string s;

	while (true) {
		unsigned int ans = 0;
		readline(cin, s);
		for (unsigned int i = 0; i < s.length(); ++i) {
			ans += s[i] - '0';
		}
		if (ans == 0) break;
		cout << ans << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'readline' was not declared in this scope
   13 |                 readline(cin, s);
      |                 ^~~~~~~~
Language: C++

#include <stdio.h>

int main()
{
    char ch[1000];
    int i, sum = 0;

    scanf(" %[^\n]", ch);

    while(ch[0] != '0'&& strlen(ch) != 1)
    {
        for(i = 0; i < strlen(ch); i++)
        {
            sum = sum + ch[i] - '0';
        }
        printf("%d\n", sum);
        scanf(" %[^\n]", ch);
        sum = 0;
    }

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:10:26: error: 'strlen' was not declared in this scope
   10 |     while(ch[0] != '0'&& strlen(ch) != 1)
      |                          ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <stdio.h>
  +++ |+#include <cstring>
    2 |
Language: C++

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

int main(){
string number;
int sum = 0;
while(1){
cin >> number;
if(nember[0] == "0")break;
for ( int i = 0; i < number.size(); i++ ){ 

  sum += number[i];
}
cout << sum << endl;	
}  
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:4: error: 'nember' was not declared in this scope; did you mean 'number'?
   12 | if(nember[0] == "0")break;
      |    ^~~~~~
      |    number
Language: C++

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

int main(){
string number;
int sum;
while(1){
sum = 0;
cin >> number;
if(nember[0] == "0")break;
for ( int i = 0; i < number.size(); i++ ){ 

  sum += number[i];
}
cout << sum << endl;	
}  
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:4: error: 'nember' was not declared in this scope; did you mean 'number'?
   14 | if(nember[0] == "0")break;
      |    ^~~~~~
      |    number
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:18:4: error: 'nember' was not declared in this scope; did you mean 'number'?
   18 | if(nember == "0")break;
      |    ^~~~~~
      |    number
Language: C++

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

int main(){
string number;
int sum;
while(1){
sum = 0;


while(number[number.size()-1] != '\n')cin >> number;
}

if(number[0] == '0' && number.size() == 1)break;

for ( int i = 0; i < number.size(); i++ ){ 
  sum += number[i] - '0';
  number[i] = '0';
}
cout << sum << endl;
}
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:43: error: break statement not within loop or switch
   18 | if(number[0] == '0' && number.size() == 1)break;
      |                                           ^~~~~
a.cc: At global scope:
a.cc:26:1: error: expected unqualified-id before 'return'
   26 | return 0;
      | ^~~~~~
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

int main()
{
	int num,dig;
	long long sum;

	while(1){
		cin >> num;

		if(num!=0){
			sum=0;
			while(num){
				dig = num%10;
				sum += dig;
				num /= 10;
			}
			cout << sum << endl;
		}
		else break;
	}


	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'cin' was not declared in this scope
    7 |                 cin >> num;
      |                 ^~~
a.cc:16:25: error: 'cout' was not declared in this scope
   16 |                         cout << sum << endl;
      |                         ^~~~
a.cc:16:40: error: 'endl' was not declared in this scope
   16 |                         cout << sum << endl;
      |                                        ^~~~
Language: C++

#define MAXSIZE 1000

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

char init_str[MAXSIZE]={};


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

	while(1){
		strcpy(str,init_str);
		scanf_s("%s",&str,MAXSIZE);
		if((int)str[0]!=0){
			sum=0;
			for(int i=0;(i<MAXSIZE&&(str[i]!='\0'));i++){
				sum += (int)(str[i]-'0');
			}
			cout << sum << endl;
		}
		else break;
	}
	return 0;
}



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

#define MAXSIZE 1000

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

char init_str[MAXSIZE]={};


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

	while(1){
		strcpy(str,init_str);
		scanf_s("%s",&str,MAXSIZE);
		if((int)(str[0]-'0')!=0){
			sum=0;
			for(int i=0;(i<MAXSIZE&&(str[i]!='\0'));i++){
				sum += (int)(str[i]-'0');
			}
			cout << sum << endl;
		}
		else break;
	}
	return 0;
}



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

#include <iostream>
using namespace std;

int main(){
    string number;
    int a;
    while(true){
        if (int(number)==0) break;
        cin>>number;
        a=0;
        for(int i=0;i<number.size();i++){
            a+=number[i];
        }
        cout<<a<<endl;
    }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    8 |         if (int(number)==0) break;
      |             ^~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

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

 int sum = 0;
 while(x > 0){
  int a = x % 10;
  sum += a;
  x = x / 10;
  }
 cout << count << endl;
}
return 0;
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'count' was not declared in this scope
   16 |  cout << count << endl;
      |          ^~~~~
Language: C++

#include<iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: 'a' was not declared in this scope
   11 |    int num = a[i] - '0';
      |              ^
Language: C++

#include<iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: array size missing in 'x'
    6 |   string x[];
      |          ^
a.cc:7:12: error: expected primary-expression before ']' token
    7 |   cin >> x[];
      |            ^
a.cc:8:8: error: comparison between distinct pointer types 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} and 'const char*' lacks a cast
    8 |   if(x == "0") break;
      |      ~~^~~~~~
a.cc:11:19: error: no match for 'operator-' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char')
   11 |    int num = x[i] - '0';
      |              ~~~~ ^ ~~~
      |                 |   |
      |                 |   char
      |                 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:11:21: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   11 |    int num = x[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:11:21: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
   11 |    int num = x[i] - '0';
      |                     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int digit(int N);
    while(N>=10)  {
        int tmp{};
        while(N>0){
            tmp+=(N%10);
            N/=10;
        }
        N=tmp;
    } 
    return N;
}
int main()
{
    int N{};
    cin>>N;
    cout<<N<<endl;
}



Compiler output:
a.cc:4:5: error: expected unqualified-id before 'while'
    4 |     while(N>=10)  {
      |     ^~~~~
a.cc:12:5: error: expected unqualified-id before 'return'
   12 |     return N;
      |     ^~~~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:38: error: expected ')' before '}' token
   11 |         for(int i=0;i<strlen(str);i++
      |            ~                         ^
      |                                      )
   12 | 
   13 |     }
      |     ~                                 
a.cc:13:5: error: expected primary-expression before '}' token
   13 |     }
      |     ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: expected ';' before '}' token
   13 |         }printf("%d\n")
      |                        ^
      |                        ;
   14 | 
   15 |     }
      |     ~
Language: C++

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

int main(void){
    string number;
    int sum;
    while(true){
        sum = 0;
        cin >> number;
        if (number = "0"){
            break;
        }
        for ( int i = 0; i < number.size(); i++ ){
            sum += stoi(number[i]);
        }
        cout << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: could not convert 'number.std::__cxx11::basic_string<char>::operator=(((const char*)"0"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   11 |         if (number = "0"){
      |             ~~~~~~~^~~~~
      |                    |
      |                    std::__cxx11::basic_string<char>
a.cc:15:24: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   15 |             sum += stoi(number[i]);
      |                    ~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

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

int main(void){
    string number;
    int sum;
    while(true){
        sum = 0;
        cin >> number;
        if (number = "0"){
            break;
        }
        for ( int i = 0; i < number.size(); i++ ){
            sum += number[i];
        }
        cout << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: could not convert 'number.std::__cxx11::basic_string<char>::operator=(((const char*)"0"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   11 |         if (number = "0"){
      |             ~~~~~~~^~~~~
      |                    |
      |                    std::__cxx11::basic_string<char>
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: could not convert 'number.std::__cxx11::basic_string<char>::operator=(((const char*)"0"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   11 |         if (number = "0"){
      |             ~~~~~~~^~~~~
      |                    |
      |                    std::__cxx11::basic_string<char>
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   11 |         if (number[0] = "0"){
      |                         ^~~
      |                         |
      |                         const char*
Language: C++

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

int main(void){
    string number;
    int sum;
    while(true){
        sum = 0;
        cin >> number;
        if (str[0] == '0'){
            break;
        }
        for ( int i = 0; i < number.size(); i++ ){
            sum += number[i];
        }
        cout << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'str' was not declared in this scope; did you mean 'std'?
   11 |         if (str[0] == '0'){
      |             ^~~
      |             std
Language: C++

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    string a;
    while(1){
        cin>>a;
        if(a=="0")break;
        int b=0;
        for(int i;i<a.size();i++){
            b += a[i]-"0";
        }
        cout<<b<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} and 'const char [2]' to binary 'operator-'
   12 |             b += a[i]-"0";
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:15:30: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} and 'const char [2]' to binary 'operator-'
   15 |             sum += number[i] - "0";
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected '(' before 'num'
   12 |         if num[0]=='0' break;
      |            ^~~
      |            (
a.cc:15:33: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   15 |         for (int i =0;i<(strlen(num));i++){
      |                                 ^~~
      |                                 |
      |                                 char
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:16:24: error: invalid types 'char[int]' for array subscript
   16 |             sum += (num[i]-'0');
      |                        ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected '(' before 'num'
   12 |         if num[0]=='0' break;
      |            ^~~
      |            (
a.cc:15:33: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   15 |         for (int i =0;i<(strlen(num));i++){
      |                                 ^~~
      |                                 |
      |                                 char
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:16:24: error: invalid types 'char[int]' for array subscript
   16 |             sum += (num[i]-'0');
      |                        ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: invalid types 'char[int]' for array subscript
   12 |         if (num[0]=='0') break;
      |                ^
a.cc:15:33: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   15 |         for (int i =0;i<(strlen(num));i++){
      |                                 ^~~
      |                                 |
      |                                 char
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:16:24: error: invalid types 'char[int]' for array subscript
   16 |             sum += (num[i]-'0');
      |                        ^
Language: C++

#include <stdio.h>
#include <string>
using namespace std;
int main(){
    string num;
    while(1){
        int sum=0;
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            for ( int i = 0; i < num.size(); i++ ){
                int number=atoi(num[i].c_str())
                sum+=number;
            }
        }cout<<sum<<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>>num;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <string>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:14:40: error: request for member 'c_str' in 'num.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   14 |                 int number=atoi(num[i].c_str())
      |                                        ^~~~~
a.cc:17:10: error: 'cout' was not declared in this scope
   17 |         }cout<<sum<<endl;
      |          ^~~~
a.cc:17:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:21: error: 'endl' was not declared in this scope
   17 |         }cout<<sum<<endl;
      |                     ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <string>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(){
    string num;
    while(1){
        int sum=0;
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            for ( int i = 0; i < num.size(); i++ ){
                int number=atoi(num[i].c_str());
                sum+=number;
            }
        }cout<<sum<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:40: error: request for member 'c_str' in 'num.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   15 |                 int number=atoi(num[i].c_str());
      |                                        ^~~~~
Language: C++

#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(){
    string num;
    while(1){
        int sum=0;
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            for ( int i = 0; i < num.size(); i++ ){
                int number=stoi(num[i]);
                sum+=number;
            }
        }cout<<sum<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   15 |                 int number=stoi(num[i]);
      |                            ~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from a.cc:2:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(){
    string num;
    while(1){
        int sum=0;
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            for ( int i = 0; i < num.size(); i++ ){
                int number=std::stoi(num[i]);
                sum+=number;
            }
        }cout<<sum<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:37: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   15 |                 int number=std::stoi(num[i]);
      |                            ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from a.cc:2:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
    string num;
    while(1){
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            int sum=0;
            for ( int i = 0; i < num.size(); i++ ){
                int number='num[i]'-'0';
                sum+=number;
            }
        }cout<<sum<<endl;
    }
    return 0;
}


Compiler output:
a.cc:13:28: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   13 |                 int number='num[i]'-'0';
      |                            ^~~~~~~~
a.cc: In function 'int main()':
a.cc:16:16: error: 'sum' was not declared in this scope; did you mean 'num'?
   16 |         }cout<<sum<<endl;
      |                ^~~
      |                num
Language: C++

#include <iostream>
using namespace std;
int main(){
    char num[1000];
    while(1){
        cin>>num;
        if (num=="0") {
            break;
        }
        else{
            int sum=0;
            for ( int i = 0; i < num.size(); i++ ){
                int number='num[i]'-'0';
                sum+=number;
            }
            cout<<sum<<endl;
        }
    }
    return 0;
}


Compiler output:
a.cc:13:28: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   13 |                 int number='num[i]'-'0';
      |                            ^~~~~~~~
a.cc: In function 'int main()':
a.cc:12:38: error: request for member 'size' in 'num', which is of non-class type 'char [1000]'
   12 |             for ( int i = 0; i < num.size(); i++ ){
      |                                      ^~~~
Language: C++

#include<stdio.h>

int main(){
    char num[4];
    gets(num);
    int sum;
    for(int i = 0;i < 4;i++){
        sum += (num[0] - '0') + (num[1] - '0') + (num[2]  - '0');
    }
    printf("%d",sum);
    sum = 0;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
    5 |     gets(num);
      |     ^~~~
      |     getw
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
    string num;
    while(1){
        scanf("%c",%num);
        if (num=="0") {
            break;
        }
        else{
            int sum=0;
            for ( int i = 0; i<num.size(); i++ ){
                int number='num[i]'-'0';
                sum+=number;
            }
            printf("%d\n",sum)
        }
    }
    return 0;
}


Compiler output:
a.cc:14:28: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   14 |                 int number='num[i]'-'0';
      |                            ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:20: error: expected primary-expression before '%' token
    7 |         scanf("%c",%num);
      |                    ^
a.cc:17:31: error: expected ';' before '}' token
   17 |             printf("%d\n",sum)
      |                               ^
      |                               ;
   18 |         }
      |         ~
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
    string num;
    while(1){
        scanf("%c",%num);
        if (num=="0") {
            break;
        }
        else{
            int sum=0;
            for ( int i = 0; i<num.size(); i++ ){
                int number='num[i]'-'0';
                sum+=number;
            }
            printf("%d\n",sum);
        }
    }
    return 0;
}


Compiler output:
a.cc:14:28: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   14 |                 int number='num[i]'-'0';
      |                            ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:20: error: expected primary-expression before '%' token
    7 |         scanf("%c",%num);
      |                    ^
Language: C++

#include<stdio.h>
#include<cctype>

int main(){
    char ch;
    int sum=0;
    while(true){
        while(ch = getchar() != \n){
            sum += ch - '0';
        }
        if(sum == 0) break;
        printf("%d",sum);
        sum = 0;
    }
    return 0;
}


Compiler output:
a.cc:8:33: error: stray '\' in program
    8 |         while(ch = getchar() != \n){
      |                                 ^
a.cc: In function 'int main()':
a.cc:8:34: error: 'n' was not declared in this scope
    8 |         while(ch = getchar() != \n){
      |                                  ^