自定义读取函数出错 找不到问题

C++小白自己编了一个函数

用来读取文件中某行以下的内容

可是运行一直报错找了好久都不知道问题在哪里

代码如下

#include<iostream>
#include <string>
#include<fstream>
using namespace std;
void read(string filename, int line);
int main()
{
    read("doll.txt", 5);
}
void read(string filename, int line)
{
    ifstream ifile;
    int i = 1;
    char text[100];
    ifile.open(filename);
    while (ifile >> text)
    {
        if(i < line)
        {
            i++;
            continue;
        }
        cout << text << endl;
    }
    ifile.close();
}

大佬看看是哪里错了呢··

代码:

#include<iostream>
#include <string>
#include<fstream>
using namespace std;
void read(string filename, int line);
int main()
{
    read("doll.txt", 5);
}
void read(string filename1, int line)
{
    const char* filename = filename1.c_str();
    ifstream ifile;
    int i = 1;
    char text[100];
    ifile.open(filename);
    while (ifile >> text)
    {
        if(i < line)
        {
            i++;
            continue;
        }
        cout << text << endl;
    }
    ifile.close();
}