15,905,558 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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.