473,803 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ 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(micros oft)
#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(con st CD[]);

CD myCD;
CD CDList[50];

int i;

int data_amt;
int response;

outfile.open("c dlist.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(fil ename, ios::in);
}
while (infile.fail()) ;



instructions();

infile>>data_am t;
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.getkeyedDa ta();
getche();
break;

//case 4: myCD.changePric e();
// 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'||menuAgai n[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 1140

"Patrick Parks" <pa**********@a delphia.net> wrote in message
news:df******** *************** **@posting.goog le.com...
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
5905
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 example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
34
2807
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 we think about is apache/oracle/php. Now, I can do oracle no problem but I'm pretty wet behind the ears about everything else. What books could you recommend to me so that I can learn: - what all this apache stuff is about, the mod_* - what...
0
4727
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 vesrion of BAC software for our backend, see www.buildacommunity.com
0
2489
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 Programming experience. The salary range for this position is 80-85K range..tops.
23
2710
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 the same consulting company. I did not initially know this other programmer's experience level, but he seemed down to earth and friendly. I saw some signs of trouble after having him try to integrate some of my code, but chalked it up to him...
11
1930
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 individual user's machines. What I need: I need code to make Access look for a "security" file located on the user's hard drive. If it finds the file, it allows the user to continue
13
2511
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 experience. We employ some parts of XP such as pair programming, and this should help. Other than books, does anyone have any suggestions? His skill set is pretty antiquated and we need to get him up to speed as quickly as possible so any suggestions...
0
5577
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
2
1354
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 salary & hours per week and could calculate your monthly, weekly & hourly pay with or without taxes taken out. Pretty nifty, but at this point I want to get into pulling data out of databases for my next test project. I have tried surfing all...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10550
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5501
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2972
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.