Guys, I'm actually almost done. Basically what I have to do is to read from file with a list of words, sort them alphabetically and write them into another file.
Sounds good so far.I am almost done, but the only thing is, the assignment says that we shouldn't change the case of words,
So don't change the case.but I am changing everything to lowercase, ...
So don't....because I'm using arrays to compare letters.
Why does that necessitate changing the case?
Either you are under a misconception vis-a-vis the assignment
or
You haven't given us the entire picture vis-a-vis upper/lower case
Side thought --
When you compare, why not just compare the lower case values using tolower() ?
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Oh so here's the assignment:
Write a program which sorts a list of words contained in a file alphabetically. Your program will sort these words alphabetically, and store the sorted list in a new file. You shouldn’t change the case of any of the letters involved.
See that last line? Do not change the letters. Period. Remove the line for(i=0; i<word.length(); i++) word.at(i)=tolower(word.at(i));
and think of another way to sort.
Like maybe use the toupper() in the sort area to compare but not change the characters.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
I've tried to use the toupper() in the sort area, but I'm getting a lot of weird errors, I think it's because all the strings are now in an array and my toupper is not working. Is there any other way to accomplish this?
Completely useless information.
First thing is stop ALL conversion. Do not use toupper() at all. Do not use tolower() at all. Get the program working with no conversions.
When you get that working, post code, explain what it's doing correctly (so far) and explain how you need it changed. With examples.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Why don't u use strcmpi()?
v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 4