Need C++ help

  • DougSpear12
  • Born
  • Born
  • DougSpear12
  • Posts: 1

Post 3+ Months Ago

Hello, my brother in law has a small home library and he wanted some way to keep track of all his books. Since I am a "computer guy" as he would like to call me, he came to me. I am teaching myself C++ in my spare time, and I thought that this would make a great progress test for me to do this project in C++. So, I have some of it done, but I am kind of confused. I don't really understand classes very well. Here is what I have so far, I hope someone could help me. If you could send me the finished code, just e-mail me at Doug128105@aol.com. He asked me a long time ago if I could do this and I have been over my head with work and I'd really appreciate the help. Thanks.


Code: [ Select ]
#include <iostream>
#include <iomanip>

using namespace std;


void getUpdateInfo(ifstream& updatefile, bookType, bookArray[arraySize], int numOfBooks);

{
   char isbntitle = ' ';//char variable to hold I or T
   string uisbn = " ";//string variable to hold isbn
   string utitle = " ";//string variable to hold title
   int ucopiesinstock = 0;//integer variable to hold Number of copies
   int ucount = 0;//integer variabe used in for statement as counter
   char ch;//char variable to hold newline character

   updatefile>>isbntitle;//gets first string I or T

   while(updatefile)//loop while updatefile is true
   {
     if('I' == isbntitle)//if first string is I
     {

     updatefile>>ucopiesinstock;//reads second string
     updatefile.get(ch);//reads the newline character
     getline(updatefile,uisbn);//reads the isbn line
     
     //for loops compare isbn to books on file
     for(ucount = 0; ucount < numOfBooks; ucount ++)
        {
          //if isbn matches one of the books
          if(uisbn == bookArray[ucount].getIsbn())
          {
             bookArray[ucount].updateCopiesInStock(ucopiesinstock);
          }
        }//end for loop
     }//end if for Isbn compare

     if('T' == isbntitle)//if first string is T
   {

     updatefile>>ucopiesinstock;//reads second string
     updatefile.get(ch);//reads the newline character
     getline(updatefile, utitle);//reads the title line
     
     //for loops compares title to books on file
     for(ucount = 0; ucount < numOfBooks; ucount ++)
     {
        //if title matches one of the books
        if(utitle == bookArray[ucount].getTitle())
        {
          bookArray[ucount].updateCopiesInStock(ucopiesinstock);
        }
     }//end of for
   }//end of if for T

     updatefile>>isbntitle;//reads next string I or T

   }//end of while
}//end of getUpdateInfo function
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. void getUpdateInfo(ifstream& updatefile, bookType, bookArray[arraySize], int numOfBooks);
  5. {
  6.    char isbntitle = ' ';//char variable to hold I or T
  7.    string uisbn = " ";//string variable to hold isbn
  8.    string utitle = " ";//string variable to hold title
  9.    int ucopiesinstock = 0;//integer variable to hold Number of copies
  10.    int ucount = 0;//integer variabe used in for statement as counter
  11.    char ch;//char variable to hold newline character
  12.    updatefile>>isbntitle;//gets first string I or T
  13.    while(updatefile)//loop while updatefile is true
  14.    {
  15.      if('I' == isbntitle)//if first string is I
  16.      {
  17.      updatefile>>ucopiesinstock;//reads second string
  18.      updatefile.get(ch);//reads the newline character
  19.      getline(updatefile,uisbn);//reads the isbn line
  20.      
  21.      //for loops compare isbn to books on file
  22.      for(ucount = 0; ucount < numOfBooks; ucount ++)
  23.         {
  24.           //if isbn matches one of the books
  25.           if(uisbn == bookArray[ucount].getIsbn())
  26.           {
  27.              bookArray[ucount].updateCopiesInStock(ucopiesinstock);
  28.           }
  29.         }//end for loop
  30.      }//end if for Isbn compare
  31.      if('T' == isbntitle)//if first string is T
  32.    {
  33.      updatefile>>ucopiesinstock;//reads second string
  34.      updatefile.get(ch);//reads the newline character
  35.      getline(updatefile, utitle);//reads the title line
  36.      
  37.      //for loops compares title to books on file
  38.      for(ucount = 0; ucount < numOfBooks; ucount ++)
  39.      {
  40.         //if title matches one of the books
  41.         if(utitle == bookArray[ucount].getTitle())
  42.         {
  43.           bookArray[ucount].updateCopiesInStock(ucopiesinstock);
  44.         }
  45.      }//end of for
  46.    }//end of if for T
  47.      updatefile>>isbntitle;//reads next string I or T
  48.    }//end of while
  49. }//end of getUpdateInfo function
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Gasolene
  • Beginner
  • Beginner
  • Gasolene
  • Posts: 39

Post 3+ Months Ago

I'm not sure people are going to be willing to finish your program for you, this board is mainly for questions and help.

you also neglected to mention what exactly the program is supposed to do. "keep track of books" is very vauge.

you should probably re-think your probelm and come up with a specific question or problem.


also, it sounds like c++ is not the best choice for this project. it sounds like your trying to create a text-file database using file i/o. and return results based on string position.

I would use a database instead of a text-file using access, vb6, or vb.net. much easier high level programming language with drag and drop interface design. (you don't even need to know vb OR sql if you use access)

for smaller applications like this, vb is definalty the way to go, c++ is mainly used for more complex powerful applications and services.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 62 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.