User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 426,441 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,257 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1222 | Replies: 1
Reply
Join Date: May 2005
Posts: 42
Reputation: TimC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
TimC TimC is offline Offline
Light Poster

Printing a Queue to file

  #1  
Jun 9th, 2005
Winbatch, I have another Q for you. I have the whole project compiling but I am stuck with displaying all the Customer details from the Q. I can pass the Class Object "Tim" to the Queue with various details but I need to write these to a file when I quit the program.

I can read in from a file and insert into the Queue but I am having difficulty printing out all the details of the Queue. As you can see I have tryed to use a method call ShowAll in the Qclass but I am unfortunately getting nowhere.

Also and this is no doubt probably the easiest Q you will ever get. When I run the prog it will work perfectly so long as I do not leave spaces between my name. e.g. Enter name: TimMurphy but if I leave a space
eg Enter name: Tim Murphy then I encounter problems. I know the solution to this is "getline" but that has not worked either.

Any help would be greatly appreciated.

Regards

Tim
Attached Files
File Type: zip Tim.zip (145.7 KB, 4 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Posts: 462
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Printing a Queue to file

  #2  
Jun 9th, 2005
Tim,

This shouldn't compile - look at this line in main.cpp

while((!in_file.eof())and (name != "")){

Even if it didn't compile, you try and read from the file if it it couldn't be opened... (Your cout says that a new file is created, I don't think that's true of an ifstream..) and even if it were, what would be the point of reading from an empty file?

Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 2:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC