I trying to read in from a file but getting runtime errors can some one help

find the .txt file as an attachment

#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<fstream>

using  namespace std;

int main()
{
    const int size= 7;
    char input[size];
    fstream nameFile;



    nameFile.open("words.txt");

    if(!nameFile)
    {
        cout<<"error cannot open file"<<endl;
        return 0;
    }

    
    nameFile.getline(input,size);
    set<char> dictionary;
    set<char>:: iterator it;
    while(!nameFile.eof())

    {
        for(int i=0;i<size;i++)
        {
        dictionary.insert(it,input[i]);
        //it++;
        }
        
        nameFile.getline(input,size);
    }



    //for(int i=0;i<size;i++)
    //{
    //    dictionary.insert(it,input[i]);
    //}
    for(it=dictionary.begin();it!=dictionary.end();it++)
    {
        cout<<" "<<*it;
    }

    cout<<dictionary.size()<<endl;

    cout<<endl;

    nameFile.close();
    system ("pause");

    return EXIT_SUCCESS;

}

    
    //    while(!nameFile.eof())
    //    {
    //        cout<<dictionary<<endl;

i would use a char array for your input but rather a string

string input;
set<string> dictionary;
// open file
while(getline(nameFile, input)) // read untill there is nothing left to read
{
    set.insert(input); // insert into set
}
// print contents
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.