my problem is that when copy another string from a file into a two-dimensional array of char gets an error: "Expression: string subscript out of range"
It needs help, not programmed much advancement so please be as easy as possible explanation and solution to my problem I add the code. Sorry for my english
int ile = 0, rozmiar = 0 ;
ifstream plik;
string slownik;
plik.open("C:\\Users\\Mateusz\\Desktop\\Krzyzowka\\slownik.txt");
ofstream plik2;
plik2.open("C:\\Users\\Mateusz\\Desktop\\Krzyzowka\\konkretny.txt");
if (plik.good())
{
cout << "Poprawnie otworzono slownik\n";
cout << "Ile znakow ma wyraz ?: ";
cin >> ile;
while (plik.good())
{
getline(plik, slownik);
if (slownik.length() == ile)
{
plik2 << slownik << endl ;
rozmiar++;
}
//cout << slownik << endl;
}
}
else
cout << "Nie udalo sie otworzyc slownika\n";
plik.close();
char **tab = new char*[rozmiar];
for (int i = 0; i < rozmiar; i++)
{
char *nowy = new char[ile];
tab[i] = nowy;
}
for (int i = 0; i < rozmiar; i++)
{
for (int j = 0; j < ile; j++)
{
tab[i][j] = slownik[j];
cout << tab[i][j];
}
cout << endl;
}