Help meeeeeeeeee!

Hi my friends.
I writing a new program,but this program have many errors.
can you help me to remove the errors.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream.h>
int calc2str(char str1[8],char str2[8])
 {
  int i,n,s2n1[8],s2n2[8];
  int result[8];
	  for(i=0;i!='\0';i++)
			if(str1[i]=='0')
				s2n1[i]=0;
			if(str1[i]=='1')
				s2n1[i]=1;
			if(str1[i]=='2')
				s2n1[i]=2;
			if(str1[i]=='3')
				s2n1[i]=3;
			if(str1[i]=='4')
				s2n1[i]=4;
			if(str1[i]=='5')
				s2n1[i]=5;
			if(str1[i]=='6')
				s2n1[i]=6;
			if(str1[i]=='7')
				s2n1[i]=7;
			if(str1[i]=='8')
				s2n1[i]=8;
			if(str1[i]=='9')
				s2n1[i]=9;
	for(i=0;i!='\0';i++)
			if(str2[i]=='0')
				s2n2[i]=0;
			if(str2[i]=='1')
				s2n2[i]=1;
			if(str2[i]=='2')
				s2n2[i]=2;
			if(str2[i]=='3')
				s2n2[i]=3;
			if(str2[i]=='4')
				s2n2[i]=4;
			if(str2[i]=='5')
				s2n2[i]=5;
			if(str2[i]=='6')
				s2n2[i]=6;
			if(str2[i]=='7')
				s2n2[i]=7;
			if(str2[i]=='8')
				s2n2[i]=8;
			if(str2[i]=='9')
				s2n2[i]=9;
	  for(i=0;i!='\0';i++);
	  for(n=0;n<=i;n++)
			result[n]=s2n1[n]+s2n2[n];

		return result;
		printstr2result(result);





 }
 int printstr2result(int result)
  {
	cout<<"result="<<result;

  }
void main(void)
 {
  char str1[8],str2[8];
  //int result;
  cin>>str1>>str2;
  calc2str(str1,str2);
  printstr2result();
 }
a) If your control structures (if, for, etc) have a body of multiple statements, you'll have to encapsulate them with { }.
b) If you want help, tell us what the problem is. I can see many problems, but I'd rather have you describe what's wrong and ask specific pointers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream.h>
void calc2str(char str1[8],char str2[8], int *result[])
 {
	int i,n,s2n1[8],s2n2[8];
	for(i=0;i!='\0';i++) {
		if(str1[i]=='0')				s2n1[i]=0;
		if(str1[i]=='1')				s2n1[i]=1;
		if(str1[i]=='2')				s2n1[i]=2;
		if(str1[i]=='3')				s2n1[i]=3;
		if(str1[i]=='4')				s2n1[i]=4;
		if(str1[i]=='5')				s2n1[i]=5;
		if(str1[i]=='6')				s2n1[i]=6;
		if(str1[i]=='7')				s2n1[i]=7;
		if(str1[i]=='8')				s2n1[i]=8;
		if(str1[i]=='9')				s2n1[i]=9;
	}
	for(i=0;i!='\0';i++) {
		if(str2[i]=='0')				s2n2[i]=0;
		if(str2[i]=='1')				s2n2[i]=1;
		if(str2[i]=='2')				s2n2[i]=2;
		if(str2[i]=='3')				s2n2[i]=3;
		if(str2[i]=='4')				s2n2[i]=4;
		if(str2[i]=='5')				s2n2[i]=5;
		if(str2[i]=='6')				s2n2[i]=6;
		if(str2[i]=='7')				s2n2[i]=7;
		if(str2[i]=='8')				s2n2[i]=8;
		if(str2[i]=='9')				s2n2[i]=9;
	}
	
	for(n=0;n<=i;n++)
			*result[n]=s2n1[n]+s2n2[n];
			
	return;
 }
 int printstr2result(int *result[])
 {
	cout<<"result="<<*result[0];
 }
void main(void)
 {
  char str1[8],str2[8];
  int result[8];
  cin>>str1>>str2;
  calc2str(str1,str2, &result);
  printstr2result();
 }


This might work beeter
First off a title name like "I'm stuck on (put your problem here)" would look more professional and encourage more people to help you. Also there are rules against posting homework assignments, and most people would prefer just the small block of code giving you problems as opposed to a wall.
Topic archived. No new replies allowed.