Trying to make a code, that will create a array of structures “simulating” a card whith to fields kind and size, write down this fields into txt file and fullfill another array of cards with data from that txt file
#include "deck.cpp"
#include <fstream>
#include <string>
using namespace std;
int main()
{
setlocale(LC_ALL, "Rus");
const int size = 36;
deck col[size];
char kind[4][13] = {"пики", "буби", "крести", "черви"};
for (int i = 0; i < size; i++) {
col[i].kind = kind[rand()%4];
col[i].size = rand() % 13 + 2;
}
ofstream out;
out.open("deck.txt");
out.clear();
for (int i = 0; i < size; i++) {
out << col[i].kind+"n" << to_string(col[i].size)+"n";
}
deck sol[size];
string line;
ifstream in("deck.txt");
int i = 0;
while (getline(in, line, 'n')) {
if (i % 2 == 0) {
sol[i / 2].kind = line;
}
else {
sol[(i - 1) / 2].size = stoi(line);
}
i++;
}
}
evrything works “fine” until it’s time to take data from file. while block ignores/ i tried changing way of inputing data, even tried use excel insted of txt, but still i didn’t get where i mistaked