Breaking the string

How would it be possible to break a string into 6 blocks for a vector. I've tried this with the code below however my success has been limited.
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
#include <iostream>
#include <string>
#include <thread>
#include <Windows.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <fstream>

using namespace std;
class Core
{
	public:
	Core();
		string data;
		string temp;
		string temp2;
		string key;
		string mode;
		string fileIn;
		string fileOut;
		
		int bufferSize;
		int mainSize;
		vector <string> ram;
	void dataBreak()
	{
		int round(0); // The total of the round
		int gear(0); // Place on Array
		int blockRounder(0); // Fills an array
		string workAround;
		string tempChar;
		while(round != 192)
		{
			if(blockRounder == bufferSize)
			{
				ram[gear] = workAround;
				workAround = "";
				cout << ram[gear];
				blockRounder = 0;
				gear++;
			}
			else
			{
				tempChar = data[round];
				
				workAround.append(tempChar);
				round++;
				blockRounder++;
			}
		}
	}
};

Core::Core()
{
	bufferSize = 6;
	mainSize = 36;
	ram.resize(6);
	ram.reserve(36);
	data.resize(36);
}

void main ()
{
	Core Function;
	Function.data = "This is a note to test stuff cuz yeah this is ment to work because yeah lol it works";
	Function.dataBreak(); 
	system("pause");
}
void main??? No. Just no. http://www.cplusplus.com/forum/beginner/19979/

Anyway, on to your question of splitting strings.
You will be glad to know that there is a function that returns a portion of a string:
http://www.cplusplus.com/reference/string/string/substr/
If you use a loop to change indices, you can easily have several parts of a string stored to a vector.
Here is an example where I split a word into individual strings that contain only one letter each.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
#include <vector>

int main() {
	std::vector<std::string> letters;
	std::string word = "Spectacular";
	
	for(size_t i = 0; i < word.size(); ++i) {
		letters.push_back(word.substr(i,1));
		std::cout << letters[i] << std::endl;
	}
	
	return 0;
}
ok
Topic archived. No new replies allowed.