If you run this program all the names of every college and university will be aligned vertically and quite frankly it looks like a mess.
For example, the name of this college in the program looks like this:
Zion
Bible
College
and I want it to look like this: Zion Bible College.
The next problem is that it doesn't show every college and university(I think it shows from W to Z and that's it. maybe because the file is to big?). How can I solve the problem?
Here is a sample of what appears in the text file.
1 2 3 4 5 6 7 8 9 10 11
name
A T Still University of Health Sciences
Abilene Christian University
Abraham Baldwin Agricultural College
Academy College
Academy For Five Element Acupuncture
Academy of Art University
Academy of Chinese Culture and Health Sciences
Academy of Oriental Medicine
ACT College
Acupuncture & Integrative Medicine College-Berkeley
while(campuses >> schools)
{
cout << schools << "\n";
}
///Might be you may use
while (campuses) /// chechs if the stream is fine.
{
getline (campuses,schools, '\n');
cout<<schools<< endl;
}
You can think of a string as an array of chars that copies until null termination. Your program is reading one string at a time then starting a new line. You can use the getline() function to get the whole line.
Well that solves the first problem but now there is a new problem.
This new problem is that it keeps repeating the name of different colleges and university several times like this:
Zion Bible college
Zion Bible college
Zion Bible college
and it still doesn't show every college and university. I'm pretty sure that every college and university is there but because there are too many characters in the file, it only shows a fraction of the entire thing.
edit1- Hold on a moment I think I found something.
edit2- Well I found that in the text file some colleges do repeat, but Zion Bible college for sure doesn't repeat so I don't know why it's repeating in the program when there's only one Zion Bible College