# Thread: What's wrong with sum up two string of integer?

1. ## What's wrong with sum up two string of integer?

Code:
```void sumString(char *a, char *b, int len)
{
int i;
for (i = 0; i < len; i++)
a[i] = (char)(((int)a[i]-48 + (int)b[i]-48) % 10);
for (i = 0; i < len; i++)
printf("%c", a[i]);
printf("\n");
}```
I wanna implement "1234"+"2345" = "3579" but It displays nothing.

2. Code:
```(a[i]-'0' + b[i]-'0') + '0';
a[i]-'0' + b[i];```
Same thing. You should make sure to deal with non-numeric input. And it's a little funky that you just modify the string a, I don't know, unless the user expects that.

3. yes, I want to modify string a, can you write it in details?

4. Well, it's just kind of a peculiar sideeffect. Like, I guess it's just a question of interpretation. I mean, I'll draw an analogous situation in C++.

Code:
```class number_string
{
number_string & operator += (const number_string &);
number_string operator + (const number_string &) const;
};```
The first operator += does modify 'this' string, like string 'a' in your case. But the second one gives back a different number_string completely in summing 'this' and 'other' number_string's. To me, that second behavior is what is expected of the sumString, but, I don't know, it's really pretty ambiguous and up to interpretation. You should just make it clear that your function does modify 'a'.

5. don't forget that 9+9=18