Scan in word per char

I have the following program:

1
2
3
4
5
6
    char* c2;
    for(char& c1 : str) {
        c2 = &c1;
        textbuf->append(c2);
        textbuf->append("Between");
    }


When str is EXAM the output of textbuf will be EXAMBetweenXAMBetweenAMBetweenMBetween
but I want the output
EBetweenXBetweenABetweenMBetween.
Does anybody know how to scan EXAM in for each char and then give me the desired output?
i'd turn each char into a string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>


int main()
{

	std::string examString("EXAM");
	std::string betweenString("between");
	std::string newLine("");

	for (char c1 : examString)
	{
		std::string charStr(1,c1);
		newLine += charStr + betweenString;
	}

	std::cout << newLine;

	return 0;
}
Topic archived. No new replies allowed.