Can you add up chars?

Hey guys, I need to create 1 char variable out of 2 other chars. For example something like this:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;
int main()
{
	char a[10];
	char b[10];
	char c[20];
	cin >> a;
	cin >> b;
	c[20] = a[10] + b[10];
	cout << "\n" << c;
}

But it isn't working, there's an error of course at the compilation. It looks like it is wrong something in the logic that I am using. Please help me.
Actually I don't care if you use different types. I just gave an example on what I am asking for.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

int main()
{
    // https://cal-linux.com/tutorials/strings.html

	std::string a ;
	std::string b ;

	std::cin >> a;
	std::cin >> b;

	const std::string c = a + b;
	std::cout << '\n' << c << '\n' ;
}
yayy, thanks man ;)
Topic archived. No new replies allowed.