Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 9th, 2008, 05:45 AM
Authorized User
 
Join Date: Jan 2007
Posts: 46
Thanks: 2
Thanked 1 Time in 1 Post
Default File I/O Operations in C++

I am developing a ticket reservation system in C++. All information will be stored in a flat file.I have the following tasks:
1. Create Reservation
2. Search Reservation
3. Update Reservation
4. Delete Reservation

Now i have done the 1st task i.e. to create reservation. Now i a, required to search a specific string(reservation number) in my file so that i can retrieve the relevant information.

Could someone guide me here on how to search a record in a text file usinf the fstream.h library? Please provide a code example, thanks.

MAXOOD!

Life is an endless journey towards perfection
__________________
MAXOOD!

Life is an endless journey towards perfection
Reply With Quote
  #2 (permalink)  
Old August 10th, 2008, 12:16 PM
Authorized User
 
Join Date: Jan 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can go to each reservation number in your file and get that substring with a standart fuction then compare it.that should continue until end of the records.for example if your reservation number starts after ':' and ends with a newline or whitespace you can extract it easily.you can use getline() function to read a whole string with a delimiter for reading reservation number and compare it.

reservation number : ...
reservation number : ...

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to roll back file system operations jomet .NET Framework 2.0 2 February 2nd, 2008 05:42 AM
Table operations Paaji Beginning VB 6 0 August 14th, 2005 03:22 PM
timespan operations marclena General .NET 1 February 25th, 2005 07:08 AM
2 ListBox operations melvik C# 1 August 19th, 2003 06:51 AM
string operations Moharo Pro PHP 2 August 18th, 2003 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.