Click here to Skip to main content
15,905,558 members

Comments by smrizvi1 (Top 4 by date)

smrizvi1 21-May-12 7:52am View    
Deleted
8,840,695 members and growing! (53,603 online)




smrizvi1




















327 Sign out .











Home
ArticlesChapters and Sections>



Search
Latest Articles
Latest Tips/Tricks
Top Articles
Beginner Articles
Video Articles
Technical Blogs
Submit an Article or Tip
Post your Blog
Posting/Update Guidelines
Article Competition

Quick AnswersAsk a Question
View Unanswered Questions
View All Questions...
C# questions
ASP.NET questions
VB.NET questions
C++ questions
C#4.0 questions

DiscussionsAll Message Boards...
Application Lifecycle> Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work & Training Issues

Design and Architecture
ASP.NET
JavaScript
C / C++ / MFC> ATL / WTL / STL
Managed C++/CLI

C#
Free Tools
Database
Hardware & Devices> System Admin

Hosting and Servers
Java
.NET Framework
Mobile
VS 11 & .NET 4.5
Sharepoint
Silverlight / WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Other Languages>General Indian Topics
General Chinese Topics


ZonesThe Commerce Zone
The Mobile & App Zone
The Cloud Zone
The Hardware Zone
The Parallelism Zone
The WPF / Silverlight Zone
The Flex / Flash Zone
The HTML5 / CSS3 Zone
SharePoint Zone
The SQL Zone
WhitePapers / Webcasts
Solutions Center

FeaturesWho's Who
Most Valuable Professionals
Company Listings
Component & Service Catalog
Competitions
News

The Insider Newsletter
Newsletter archive
Press Releases
Surveys
CodeProject Stuff


Help!What is 'The Code Project'?
General FAQ
Post a Question
Bugs and Suggestions
Site Map
Advertise with us
About Us

The LoungeThe Insider News
The Lounge
Clever Code
Hall of Shame
The Soapbox

.






























Ask a Question
All QuestionsAll UnansweredMineFAQ
.


Next


Code to Search book by its author from 1st record to last













See more:C++Sortingsearchstrings
Hey everyone! i stuck here with a thing. I use this code in visual c++ to search a book by its author. I have used the approach of bubble sorting then binary searching.

Alright, now this is what i have. what i want to do now is to search a particular BOOK by its author without using the bubble sorting or binary searching method and instead search all the records one at a time, from start till the end for its author. I think the improved approach will make the coding a lot shorter than it is now


Collapse | Copy Code
//***************************************************************
// HEADER FILE USED IN PROJECT
//****************************************************************

#include<fstream>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip>
#include<iostream>


using namespace std;

class BOOK
{
public:
char ID[6];
char Content[50];
char AUTHOR[20];
char Book[20];
}

void Copy(BOOK hd){ // this function copies whole record
strcpy(ID,(hd.ID)); //copy BOOK ki id
strcpy(AUTHOR,(hd.AUTHOR)); // copy BOOK ka AUTHOR
strcpy(Book,(hd.Book));
strcpy(Content,(hd.Content));
}




void SwapBOOK(BOOK &bk1, BOOK &bk2){ //swaps position of BOOK1 with BOOK2

BOOK Temp;

Temp.Copy(bk1); //BOOK1 ko temp main copy kiya
bk1.Copy(bk2); //BOOK2 ko BOOK1 main copy kiya (now BOOK2 has moved to the place of BOOK1)
bk2.Copy(Temp); //BOOK1 ko finalyy BOOK2 ki jaga per copy ker diya
}


//***************************************************************
// global declaration for stream object, object
//****************************************************************
fstream fp; // fstream provides an interface to read and write data from files as input/output streams.
ofstream ofp; // ofstream provides an interface to write data to files as output streams
//***************************************************************
// SORT AND SEARCH BY AUTHOR (START)
//****************************************************************



void SortByAUTHOR() // bubble sort
{
for(int i=0; i< countBOOK-1; i++){
for(int
smrizvi1 12-May-12 9:18am View    
The problem is that I have got to do this myself. My boss asks for atleast the file handling code till coming monday. Where as i have to submit the whole task ,on visual c++, by the end of next week! I already have copied most of my records on a text file sir. And now i really want to do it that way! Only if you could help me with this please?
smrizvi1 12-May-12 8:56am View    
Sir, do you think that this is the best format for turning these records to arrays and searching from them?
smrizvi1 12-May-12 8:51am View    
No i did not. I am not very familiar with Visual C++. I work in a library and have been given this task. My friend suggested me to copy all the records to a text file. He said with c++ we can search data in text file very easily. I am trying to find a solution on the internet, although there has been no luck.