|
-
May 7th, 2008, 10:56 PM
#1
c++ project problem
hello everyone out there.
my first time trying this kind of web site. i need help in my project if anyone can please.
I need to pull out text line from a file in alphabetical order by the name. example data is saved in a file called sample.txt. i just don't know where to start from. i could have put my own program to show, but i really have no clue where to start from. Please someone help me get it right. thanx
example:
Tony | Tacoma | WA | $5,435.00
Eric | Issaquah | WA | $1,238.00
John | Beaver Creek | OR | $345.00
output should be:
Eric | Issaquah | WA | $1,238.00
John | Beaver Creek | OR | $345.00
Tony | Tacoma | WA | $5,435.00
-
May 8th, 2008, 12:51 AM
#2
Re: c++ project problem
One possible way of doing it.
1. Read each line from the file until EOF is encountered.
2. Store each line in a string buffer.
3. Sort the buffer.
Do, you have knowledge of std::string or std::priority_queue?
-
May 8th, 2008, 08:36 PM
#3
Re: c++ project problem
This should get you started.
Code:
#include <iostream>
int main()
{
std::cout << "Start writing program here!" << std::endl;
return 0;
}
Take a look at these:
http://www.research.att.com/~bs/bs_faq.html
http://www.research.att.com/~bs/bs_faq2.html
http://www.cplusplus.com/reference/iostream/fstream/
Last edited by kempofighter; May 12th, 2008 at 10:12 AM.
Reason: added std::
-
May 9th, 2008, 05:43 PM
#4
Re: c++ project problem
 Originally Posted by kempofighter
Code:
std::cout << "Start writing program here!" << endl;
The above code won't compile - std:: is missing in front of endl ... i.e. it should be:
Code:
std::cout << "Start writing program here!" << std::endl;
-
May 12th, 2008, 10:27 PM
#5
Re: c++ project problem
Thank you mr rohit for your help, but i have no clue how to save a line in a string. if you can please do this huge favor and write this small program, i will b very thankful to u.
-
May 12th, 2008, 10:43 PM
#6
Re: c++ project problem
 Originally Posted by ali09
if you can please do this huge favor and write this small program, i will b very thankful to u.
Read this.
-
May 13th, 2008, 05:18 AM
#7
Re: c++ project problem
 Originally Posted by ali09
Thank you mr rohit for your help, but i have no clue how to save a line in a string. if you can please do this huge favor and write this small program, i will b very thankful to u.
I'm sorry ali09. That would be most unethical. As the saying goes - "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." However, I would be glad to see you at least try something. Post your attempt at a working solution here and I will nudge you in the write direction. I'm here to help but not to spoon-feed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|