The following is my "inFile":
UEAALEUE
RIXETOHI
BACOZOEI
DIUEAOAU
ZIKOFIMO
RESUZEAE
IIJEHUMO
EEQINOXO
TAOEKIBI
RUQICIGU
ZIWAREWE
HIDIFIFO
MOIACALA
MEJIEACO
UAPEUUQU
YISOZAZO
KENIDONA
EEVIYOHU
SEJEXEYA
OESEQUFU
NUJECAUE
RAKAWUME
NISIMAKE
MEPIBADO
TAUELAZI
IIEACINU
IITOGIIE
GIEIFEVU
NIOUQELU
IIVOFEHI
TOKUCORU
GUQOEOJE
HOBUUIXA
HOVEDAGO
JEROMAFA
TOLIOELU
QIGOIIAA
TEDEIUOA
COZOLELA
YOHUZUZA
QUNACAKO
POSAEIGA
JECAMOPE
VAKEKAPA
LEJEVINE
SONEBAEE
PEBINUGO
KONUNINE
BERIWUQO
WEXOIOVU
HIXUQIAE
IODOAUIE
HAKESUFA
ZIAIWAXA
DAGOGEBE
CUHIUAOO
DAVUAETU
COAUBAKU
IIMOJOLE
UIKIBUWU
SOEAOILA
VEGUKAXA
AUMATOUO
JOSUZIXI
COUOFUWI
ZILUAISU
SEZEIAVO
DEFISIZA
GOSUEUFO
ZEEAMAIA
POROEIDI
REGEJUPO
YUZUAOXU
AUZUXANI
SIZUZIEO
KIBEROWO
WEGIEAFA
PIPAAURI
UEJIEAZE
VIPIVICE
CASISUIO
FENOBOFU
GULEUEKO
NEUIGIJU
LICOXUDO
EUZAIAUA
LOUIOARU
DOKOWUUE
NEIIUEQO
FORUMOQU
KIWOOUXO
ZEMAFAIO
NAJEOAQI
YOIIBUFI
QOUOFIPE
EAOAPIMO
FAQALOLE
XEGIJELE
WOQEJAPO
XEOETUGE
BAEIUITA
DIHODETI
PUFIYARA
OEVINAYU
PIUOCOXI
YIBIZEOI
EADIGAFO
EUFENABU
HILAKOYE
DITAJARI
WEEIOOZA
TIAUSEAO
ZOVUROPA
PAQAWIRU
KUBOGESE
ZIZUAEOI
RAXUHAFU
The question is: Write a program that will read an unknown number of single names (of jumbled letters) into an array from a file named “listnames.txt”. There are no more than 120 names in the list. Sort the names in normal alphabetical order and then display them to the screen and print printer in 5 columns.
Any assistance is appreciated...The following (below) is what I have so far....but I want to make sure.....a couple things:
1st. The program keeps repeating the the groups of letters on the first line..why does it not read in the data from each line?
2nd. For right now..the program won't run....is it because of how I have my string 'names' declared? I pretty much want the program to read from the 'inFile' into an array..is my declaration ok?
3. I'm kinna familiar with BubbleSort...but only for numeric values... how can I sort the names in normal alphabetical order.
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("listnames.txt");
outFile.open ("outnames");
string names[120];
inFile>>names;
int num;
for (num=0; num<120; num++)
outFile<<names<<"Hello"<<endl;
int i;
for (i=0; i<120; i++)
{
if (i%5 ==0)
cout<<endl;
cout<<setw(10)<<names[120];
}
inFile.close();
outFile.close();
return 0;
}