Есть файл .txt в нем строки типа
1-я строка: 1) "какой-то текст" 2) какой-то текст 3)...
2-я строка: 1) "какой-то текст" 2) какой-то текст 3)...
Как присвоить строку классу исходя из кол-ва символов в строке? Например строка из 100 символов присваивается классу Stosimb
. Это весь код, который смог написать.
p.s. Компилируемый код.
#include <string>
#include <fstream>
#include <Windows.h>
#include <cstring>
using namespace std;
/*class Msg
{
Public:
Msg(){}
Msg(string ms)
{
this->ms = ms;
}
void Print()
{cout << ms << endl; }
char ms;
}*/
int main()
{
//ifstream fin;
fstream fs;
fs.open("myfile.txt", fstream::in | fstream::app);
while(!fs.eof())
for (int i = 0; i < 2; i++)
{
string msg;
SetConsoleOutputCP(1251);
getline(fs, msg);
cout << msg << " ";
cout << msg.length() << " characters\n";
/*while(fin.read((char*)&msg, sizeof(Msg)))
{
ms.Print();
}*/
}
fs.close();
//ifs.close();
}