Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,935 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,652 people online right now. Registration is fast and FREE... Join Now!




i/o stream manipulation

 
Reply to this topicStart new topic

i/o stream manipulation, this is like a grocery store with inventory( can add remove product)

rjayyy_15
15 Oct, 2007 - 08:11 PM
Post #1

New D.I.C Head
*

Joined: 14 Oct, 2007
Posts: 2


My Contributions
//THIS IS A I/O STREAM MANIPULATION
//MY PROBLEM IS PLEASE CONTINUE TO CREATE THIS PROGRAM ( CAN ADD/REMOVE PRODUCT)
//SHOWS THE AMOUNT OF PURCHASED AND ITS CHANGE..

#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
#include<stdlib.h>

void OpenFile();
void ProcessLoop();
void Getfile();
void Payment();
void Output();

ifstream prodFile;
char lists[45];
float price;

//ofstream prnt("products.dat");
void main()
{

OpenFile();
if (!prodFile.fail())
{
ProcessLoop();
cout<<endl;


}
prodFile.close();
}

void OpenFile()
{
prodFile.open("lists.txt");
if (prodFile.fail())
cout<<"products' file open failed.";
return;
}
void ProcessLoop(void)
{
Getfile();
while (!prodFile.eof())
{
Output();
Getfile();
}
return;
}
void Getfile()
{
prodFile.get(lists, 45)>>price;
prodFile.get();
return;
}
void Output()
{
// prnt<< products;
cout<< setw(25)<< lists<< setw(4)
<< setiosflags(ios::fixed)<< setiosflags(ios::showpoint)
<< setw(10)<< setprecision(2) << price << endl;
return;
}


//THIS IS LIST.TXT FILE( LIST OF PRODUCT WITH THEIR PRICE)
SAFEGUARD
8.00
PALMOLIVE
9.00
BIODERM
8.00
COLGATE
7.50
CLOSE-UP
7.00
HAPEE
6.50
TIDE
8.50
SURF
7.50
ARIEL
9.00
HEAD AND SHOULDER
4.50
SUNSILK
3.50
PANTENE
4.00
MAGI
6.00
LUCKY ME
5.50
QUICK CHOW
6.00
DEL MONTE
24.00
PAPA
18.00
UFC
17.00
GATSBY
70.00
TRICKS
60.00
MASTER
40.00
MINOLA
40.00
GOLDEN FRIES
36.00
ORIENTAL
37.50
BAMBINI
23.00
JOHNSON
20.00
ELLIPSE
17.00
FAMILY
17.00
GREENCROSS
16.00
ISOCROPYL
16.50




User is offlineProfile CardPM
+Quote Post

jjhaag
RE: I/o Stream Manipulation
16 Oct, 2007 - 02:48 AM
Post #2

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 1 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
Please post code using the code tags.

You aren't likely to find anyone who is going to just continue writing your code for you. If you are having problems with it, please ask specific questions and we can try to help address errors, point you in the right direction, etc.

-jjh
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 08:33AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month