Написать программу, которая считывает текст из файла и выводит на экран только предложения, не содержащие запятых

Программу написал, но предложение выводится иероглифами, помогите пожалуйста, что я делаю не так.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

ofstream fout;
ifstream fin;

int main()
{
    // input stream
    std::ifstream fin("text.txt", std::ios::in | std::ios::binary);
    if (!fin)
    {
        std::cout << "Error " << std::endl;
        return 0;
    }

    // get file size
    fin.seekg(0, std::ios_base::end);
    int file_size = fin.tellg();
    fin.seekg(0, std::ios_base::beg);
    // read file
    char* buf = new char[file_size + 1];
    std::string line;
    getline(fin, line);
    int index = 0;
    for (int i = 0; i < file_size; i++) {
        char c = line[i];
        if (c == '.' || c == '?' || c == '!' || c == ':' || c == ';') {
            std::string s = line.substr(index, i + 1);
            index = i + 1;
            if (s.find(',') == -1) {
                std::cout << s;
            }
        }
    }

    std::cout << std::endl;
    system("pause");
    return 0;
}

Вот пример текста: What's my problem? First of all, I'm a rat. Which means, life is hard. Second, I have a highly developed sense of taste and smell.

Вывод должен быть такой: What's my problem?


Ответы (0 шт):