473,473 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

new programmer needs some help

hi guys, i am trying to read in CD info from a file and put it into an
array, using a CD class. I have been working here for about 6-8 hours
trying to get the input file into an array. i just need some help
starting it. It needs to read 15 15 rows with 6 columns in each row.
Any help???

thx a bunch.....

#if !defined(microsoft)
#include
#define cls() system ("cls");
#endif

#include
#include
#include
#include
#include
using namespace std;

class CD
{
private:
int numberID1;
char nameArtist[20];
int numSongs;
char genderArtist[10];
float cdPrice;
char artistLabel[25];
char cdArray[15];

public:

CD(); // default constructor

void getData(); //getData
void reportData();
void getkeyedData();
~CD(); //destructor

};

CD::CD()//constructor
{
numberID1 = 0;
nameArtist[0] = '\0';
numSongs = 0;
genderArtist[0] = '\0';
cdPrice = 0;
artistLabel[0] = '\0';
}

CD::~CD()//destructor
{

}
ifstream infile;
ofstream outfile;
ofstream errorlog;

int main ()
{

void instructions();
int menu();
void printCDList(const CD[]);

CD myCD;
CD CDList[50];

int i;

int data_amt;
int response;

outfile.open("cdlist.txt");
errorlog.open("errorlog.txt");
arraytest.open("arraytest.txt");


do
{
char filename[80];

infile.clear();
cout << "Please enter the name of the file with the CD information in
it: ";
cin >> filename;
infile.open(filename, ios::in);
}
while (infile.fail());



instructions();

infile>>data_amt;
for(i=1; i<=data_amt; i++)
{
cout << "CD #" << i <<endl;
myCD.getData();
getche();
CDList[i]=myCD;

}
getche();

response = menu();

switch(response)
{

//case 1: myCD.idSort();
// getche();
// break;

//case 2: myCD.artistSort();
// getche();
// break;

case 3: myCD.getkeyedData();
getche();
break;

//case 4: myCD.changePrice();
// getche();
// break;

case 5: myCD.reportData();
cout << "Printing report......" << endl;
cout << "Please hit enter to finish report" << endl;
getche();
break;

case 6: break;

}
return 0;
}//end of main
/*

}

if(menuAgain[0]=='Y'||menuAgain[0]=='y')
{
getche();
menu();
}
else
cout << "Thank you for using this program. Goodbye!" << endl;

getche();
return 0;
}

//************************************************** ********************
// Function Name: instructions
// Purpose: To explain to the user what the program will do
// Parameters:
// Input:
// Input & Output:
// Return Value:
// Non-local Variables Used:
// Functions Called:
//************************************************** ********************

*/
void instructions()
{
cout << "This program will allow you to enter the information for a CD
from the keyboard and from a file." << endl;
cout << "It will accept: " << endl;
cout << "The UPC code on the CD, the Artist's name, the gender of the
artist, the number of songs on the CD, the price of the CD, and the
label that released the CD" << endl;
}

int menu()
{

int ans;
do
{
cls();
cout<<"Choose from one of the following options:"<<endl;
cout<<"1. Sort and display the list of CD's by ID number"<<endl;
cout<<"2. Sort and display the list of CD's by Artists name"<< endl;
cout<<"3. Enter a new CD from the keyboard"<<endl;
cout<<"4. Change the price of one of the CD's"<<endl;
cout<<"5. Create a report of the CD's sorted by ID number"<<endl;
cout<<"6. Exit this program"<<endl;
cin>> ans;

}
while((ans<1)||(ans>6));

return ans;
}
Jul 22 '05 #1
1 1126

"Patrick Parks" <pa**********@adelphia.net> wrote in message
news:df*************************@posting.google.co m...
hi guys, i am trying to read in CD info from a file and put it into an
array, using a CD class. I have been working here for about 6-8 hours
trying to get the input file into an array. i just need some help
starting it. It needs to read 15 15 rows with 6 columns in each row.
Any help???


Don't mix non-standard I/O functions like getche() with standard C++ I/O,
that is guaranteed to drive you bonkers. In fact don't use non-standard I/O
at all.

Apart from that I don't see any real problems, what exactly is going wrong?
Even if you've made some attempts and they didn't work its a good idea to
post that code because

1) It show more clearly what you are trying to do than any description can.
2) It demonstrates what your level of skill is, and where there are gaps in
your knowledge
3) It proves you been trying for yourself (people don't like to do others
homework when they haven't made any effort).

It would also help to post a sample of the file you are trying to read.

john
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
34
by: Volker Hetzer | last post by:
Hi! I've done lots of programming for CAD, which was basically C/C++ and tcl/tk. Now, we are thinking about introducing more web based tools, programming them ourselves and right now the toolchain...
0
by: Greg | last post by:
We're looking for CGI/PERL programmer who can help us integrate CamFrogWeb's video conferencing software with our site's user management system (login system) Our site uses customized...
0
by: Bill Law | last post by:
Great Company on the Maryland Eastern Shore needs a DB2 Systems Programmer and DBA (DB2) to join their IT team. The selected candidate MUST have a BS degree and both DB2 DBA And DB2 Systems...
23
by: Steve Jorgensen | last post by:
Hi all, I'm working on a project through a consulting company, and I'm writing some database code for use in another programmer's project in Excel/VBA. The other programmer is working through...
11
by: Wilsoch | last post by:
Long story short: My Access developer is letting me down. He doesn't really know VB and he can't figure out how to do what I need. Situation: Access database that will be used locally on...
13
by: BK | last post by:
Our .Net team has just inherited a junior programmer that we need to get up to speed as quickly as possible. Unfortunately, his skill set is largely Access with some VB6 and ASP classic...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: CSharp-Jay | last post by:
So I have been working pretty hard on the C# coding, and I am doing pretty well so far at it. I started out with simple console apps and eventually made a little windows application that took your...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.