Start New Discussion within our Software Development Community

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;
Attachments
aahed
aalii
aargh
abaca
abaci
aback
abaft
abaka
abamp
abase
abash
abate
abbas
abbes
abbey
abbot
abeam
abele
abets
abhor
abide
abler
ables
abmho
abode
abohm
aboil
aboma
aboon
abort
about
above
abris
abuse
abuts
abuzz
abyes
abysm
abyss
acari
acerb
aceta
ached
aches
achoo
acids
acidy
acing
acini
ackee
acmes
acmic
acned
acnes
acock
acold
acorn
acred
acres
acrid
acted
actin
actor
acute
acyls
adage
adapt
addax
added
adder
addle
adeem
adept
adieu
adios
adits
adman
admen
admit
admix
adobe
adobo
adopt
adore
adorn
adown
adoze
adult
adunc
adust
adyta
adzes
aecia
aedes
aegis
aeons
aerie
afars
affix
afire
afoot
afore
afoul
afrit
after
again
agama
agape
agars
agate
agave
agaze
agene
agent
agers
agger
aggie
aggro
aghas
agile
aging
agios
agism
agist
aglee
aglet
agley
aglow
agmas
agone
agons
agony
agora
agree
agria
agues
ahead
ahold
ahull
aided
aider
aides
ailed
aimed
aimer
aioli
aired
airer
airns
airth
airts
aisle
aitch
aiver
ajiva
ajuga
akees
akela
akene
alack
alamo
aland
alane
alang
alans
alant
alarm
alary
alate
albas
album
alcid
alder
aldol
alecs
alefs
aleph
alert
alfas
algae
algal
algas
algid
algin
algor
algum
alias
alibi
alien
alifs
align
alike
aline
alist
alive
aliya
alkyd
alkyl
allay
allee
alley
allod
allot
allow
alloy
allyl
almah
almas
almeh
almes
almud
almug
aloes
aloft
aloha
aloin
alone
along
aloof
aloud
alpha
altar
alter
altho
altos
alula
alums
alway
amahs
amain
amass
amaze
amber
ambit
amble
ambos
ambry
ameba
ameer
amend
amens
ament
amias
amice
amici
amide
amido
amids
amies
amiga
amigo
amine
amino
amins
amirs
amiss
amity
ammos
amnia
amnic
amnio
amoks
amole
among
amort
amour
ample
amply
ampul
amuck
amuse
amyls
ancon
anear
anele
anent
angas
angel
anger
angle
angry
angst
anile
anils
anima
anime
animi
anion
anise
ankhs
ankle
ankus
anlas
annal
annas
annex
annoy
annul
anoas
anode
anole
anomy
ansae
antae
antas
anted
antes
antic
antis
antra
antre
antsy
anvil
aorta
apace
apart
apeak
apeek
apers
apery
aphid
aphis
apian
aping
apish
apnea
apods
aport
appal
appel
apple
apply
apres
apron
apses
apsis
apter
aptly
aquae
aquas
araks
arbor
arced
arcus
ardeb
ardor
areae
areal
areas
areca
areic
arena
arete
argal
argil
argle
argol
argon
argot
argue
argus
arhat
arias
ariel
arils
arise
arles
armed
armer
armet
armor
aroid
aroma
arose
arpen
arras
array
arris
arrow
arses
arsis
arson
artal
artel
artsy
arums
arval
arvos
aryls
asana
ascot
ascus
asdic
ashed
ashen
ashes
aside
asked
asker
askew
askoi
askos
aspen
asper
aspic
aspis
assai
assay
assed
asset
aster
astir
asyla
ataps
ataxy
atilt
atlas
atman
atmas
atoll
atoms
atomy
atone
atony
atopy
atria
atrip
attar
attic
audad
audio
audit
auger
aught
augur
aulic
aunts
aunty
aurae
aural
aurar
auras
aurei
aures
auric
auris
aurum
autos
auxin
avail
avant
avast
avens
avers
avert
avgas
avian
avion
aviso
avoid
avows
await
awake
award
aware
awash
awful
awing
awned
awoke
awols
axels
axial
axile
axils
axing
axiom
axion
axite
axled
axles
axman
axmen
axone
axons
ayahs
ayins
azans
azide
azido
azine
azlon
azoic
azole
azons
azote
azoth
azure
baaed
baals
babas
babel
babes
babka
baboo
babul
babus
bacca
backs
bacon
baddy
badge
badly
baffs
baffy
bagel
baggy
bahts
bails
bairn
baith
baits
baiza
baize
baked
baker
bakes
balas
balds
baldy
baled
baler
bales
balks
balky
balls
bally
balms
balmy
balsa
banal
banco
bands
bandy
baned
banes
bangs
banjo
banks
banns
banty
barbe
barbs
barde
bards
bared
barer
bares
barfs
barge
baric
barks
barky
barms
barmy
barns
barny
baron
barre
barye
basal
based
baser
bases
basic
basil
basin
basis
basks
bassi
basso
bassy
baste
basts
batch
bated
bates
bathe
baths
batik
baton
batts
battu
batty
bauds
baulk
bawds
bawdy
bawls
bawty
bayed
bayou
bazar
bazoo
beach
beads
beady
beaks
beaky
beams
beamy
beano
beans
beard
bears
beast
beats
beaus
beaut
beaux
bebop
becap
becks
bedel
bedew
bedim
beech
beefs
beefy
beeps
beers
beery
beets
befit
befog
began
begat
beget
begin
begot
begum
begun
beige
beigy
being
belay
belch
belga
belie
belle
bells
belly
below
belts
bemas
bemix
bench
bends
bendy
benes
benne
benni
benny
bents
beret
bergs
berme
berms
berry
berth
beryl
beset
besom
besot
bests
betas
betel
beths
beton
betta
bevel
bevor
bewig
bezel
bezil
bhang
bhoot
bhuts
biali
bialy
bibbs
bible
bices
biddy
bided
bider
bides
bidet
bield
biers
biffs
biffy
bifid
bight
bigly
bigot
bijou
biked
biker
bikes
bikie
bilbo
biles
bilge
bilgy
bilks
bills
billy
bimah
bimas
bimbo
binal
bindi
binds
bines
binge
bingo
binit
bints
biome
biont
biota
biped
bipod
birch
birds
birks
birle
birls
birrs
birse
birth
bises
bisks
bison
biter
bites
bitsy
bitts
bitty
bizes
blabs
black
blade
blahs
blain
blame
blams
bland
blank
blare
blase
blast
blate
blats
blawn
blaws
blaze
bleak
blear
bleat
blebs
bleed
bleep
blend
blent
bless
blest
blets
blimp
blimy
blind
blini
blink
blips
bliss
blite
blitz
bloat
blobs
block
blocs
bloke
blond
blood
bloom
bloop
blots
blown
blows
blowy
blubs
blued
bluer
blues
bluet
bluey
bluff
blume
blunt
blurb
blurs
blurt
blush
blype
board
boars
boart
boast
boats
bobby
bocce
bocci
boche
bocks
boded
bodes
boffo
boffs
bogan
bogey
boggy
bogie
bogle
bogus
bohea
boils
boing
boite
bolar
bolas
bolds
boles
bolls
bolos
bolts
bolus
bombe
bombs
bonds
boned
boner
bones
boney
bongo
bongs
bonks
bonne
bonny
bonus
bonze
boobs
booby
booed
boogy
books
booms
boomy
boons
boors
boost
booth
boots
booty
booze
boozy
boral
boras
borax
bored
borer
bores
boric
borne
boron
borts
borty
bortz
bosks
bosky
bosom
boson
bossy
bosun
botas
botch
botel
bothy
botts
bough
boule
bound
bourg
bourn
bouse
bousy
bouts
bovid
bowed
bowel
bower
bowls
bowse
boxed
boxer
boxes
boyar
boyla
boyos
bozos
brace
brach
bract
brads
braes
brags
braid
brail
brain
brake
braky
brand
brank
brans
brant
brash
brass
brats
brava
brave
bravi
bravo
brawl
brawn
braws
braxy
brays
braza
braze
bread
break
bream
brede
breed
brees
brens
brent
breve
brews
briar
bribe
brick
bride
brief
brier
bries
brigs
brill
brims
brine
bring
brink
brins
briny
brios
brisk
brits
britt
broad
brock
broil
broke
brome
bromo
bronc
brood
brook
broom
broos
brose
brosy
broth
brown
brows
brugh
bruin
bruit
brume
brunt
brush
brusk
brute
bubal
bubby
bucko
bucks
buddy
budge
buffi
buffo
buffs
buffy
buggy
bugle
buhls
buhrs
build
built
bulbs
bulge
bulgy
bulks
bulky
bulla
bulls
bully
bumfs
bumph
bumps
bumpy
bunch
bunco
bunds
bundt
bungs
bunko
bunks
bunns
bunny
bunts
bunya
buoys
buran
buras
burbs
burds
buret
burgh
burgs
burin
burke
burls
burly
burns
burnt
burps
burro
burrs
burry
bursa
burse
burst
busby
bused
buses
bushy
busks
busts
busty
butch
buteo
butes
butle
butte
butty
butut
butyl
buxom
buyer
bwana
bylaw
byres
byrls
byssi
bytes
byway
cabal
cabby
caber
cabin
cable
cabob
cacao
cacas
cache
cacti
caddy
cades
cadet
cadge
cadgy
cadis
cadre
caeca
cafes
caffs
caged
cager
cages
cagey
cahow
caids
cains
caird
cairn
cajon
caked
cakes
cakey
calfs
calif
calix
calks
calla
calls
calms
calos
calve
calyx
camas
camel
cameo
cames
campi
campo
camps
campy
canal
candy
caned
caner
canes
canid
canna
canny
canoe
canon
canso
canst
canto
cants
canty
caped
caper
capes
caphs
capon
capos
caput
carat
carbo
carbs
cards
cared
carer
cares
caret
carex
cargo
carks
carle
carls
carns
carny
carob
carol
carom
carpi
carps
carrs
carry
carse
carte
carts
carve
casas
cased
cases
casks
casky
caste
casts
casus
catch
cater
cates
catty
cauld
caulk
cauls
cause
caved
caver
caves
cavie
cavil
cawed
cease
cebid
cecal
cecum
cedar
ceded
ceder
cedes
cedis
ceiba
ceils
celeb
cella
celli
cello
cells
celom
celts
cense
cento
cents
centu
ceorl
cepes
cerci
cered
ceres
ceria
ceric
ceros
cesta
cesti
cetes
chads
chafe
chaff
chain
chair
chalk
champ
chams
chang
chant
chaos
chape
chaps
chapt
chard
chare
chark
charm
charr
chars
chart
chary
chase
chasm
chats
chaws
chays
cheap
cheat
check
cheek
cheep
cheer
chefs
chela
chemo
chert
chess
chest
cheth
chevy
chews
chewy
chiao
chias
chick
chico
chics
chide
chief
chiel
child
chile
chili
chill
chimb
chime
chimp
china
chine
chink
chino
chins
chips
chirk
chirm
chiro
chirp
chirr
chits
chive
chivy
chock
choir
choke
choky
cholo
chomp
chook
chops
chord
chore
chose
chott
chows
chubs
chuck
chufa
chuff
chugs
chump
chums
chunk
churl
churn
churr
chute
chyle
chyme
cibol
cider
cigar
cilia
cimex
cinch
cines
cions
circa
cires
cirri
cisco
cissy
cists
cited
citer
cites
civet
civic
civie
civil
civvy
clach
clack
clade
clads
clags
claim
clamp
clams
clang
clank
clans
claps
clapt
claro
clary
clash
clasp
class
clast
clave
clavi
claws
clays
clean
clear
cleat
cleek
clefs
cleft
clepe
clept
clerk
clews
click
cliff
clift
climb
clime
cline
cling
clink
clips
clipt
clits
cloak
clock
clods
clogs
clomb
clomp
clone
clonk
clons
cloot
clops
close
cloth
clots
cloud
clour
clout
clove
clown
cloys
cloze
clubs
cluck
clued
clues
clump
clung
clunk
coach
coact
coala
coals
coaly
coapt
coast
coati
coats
cobbs
cobby
cobia
coble
cobra
cocas
cocci
cocks
cocky
cocoa
cocos
codas
codec
coded
coden
coder
codes
codex
codon
coeds
coffs

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
This article has been dead for over six months. Start a new discussion instead.