2d vector use

so i'm suppose to create a program that inputs a cross word with its words to find and the program finds the words for you..so far i only the code for reading in the crossword. i got stuck can someone jst point me in a good direction and help me out on reading at least finding the words that are just across.

#include <iostream>
#include <vector>

using namespace std;

int main()
{


vector<vector<char> > puzzle;
vector<char> row;
string line;
do{
getline(cin, line);
if(line.empty())
{
return 0; //break because return alone won't work
}
for(int i = 0; i < line.size(); ++i)
{
if(isalpha(line.at(i)))
{
row.push_back(line.at(i));
}
}
puzzle.push_back(row);
row.clear();
}while(true);


//<< puzzle.at(0).at(puzzle.at(0).size-1);

string word;
cin >> word;
char broke;
//char one;

for(int i = 0; i < word.size(); ++i)
{
broke = word.at(i);
cout << broke << " " << endl;
for (int x = 0; i < broke.size(); ++x)
{
if(broke == puzzle.at(i))
{
}
}


}













}
so it's possible to read and use line number to make a comment
please use code tags "<>" next time


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
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<vector<char>> puzzle;
	vector<char> row;
	string line;
	
		do{
		getline(cin, line);

		if(line.empty())
		{
			return 0; //break because return alone won't work
		}
		for(int i = 0; i < line.size(); ++i)
		{
			if(isalpha(line.at(i)))
			{
				row.push_back(line.at(i));
			}
		}
		puzzle.push_back(row);
		row.clear();
	}while(true);


	//<< puzzle.at(0).at(puzzle.at(0).size-1);

	string word;
	cin >> word;
	char broke;
	//char one;

	for(int i = 0; i < word.size(); ++i)
	{
	broke = word.at(i);
	cout << broke << " " << endl;
	for (int x = 0; i < broke.size(); ++x)
	{
		if(broke == puzzle.at(i))
		{
		}
	}
}



string requires #include <string>
line 42 broke is a char. char does not have the function size()
Last edited on
Topic archived. No new replies allowed.