Click here to Skip to main content
15,929,686 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralRe: Article Idea: Website from start to finish Pin
Brad Bruce7-Jun-02 6:29
Brad Bruce7-Jun-02 6:29 
GeneralRe: Article Idea: Website from start to finish Pin
Paul Watson7-Jun-02 6:36
sitebuilderPaul Watson7-Jun-02 6:36 
GeneralRe: Article Idea: Website from start to finish Pin
brianwelsch14-Aug-02 8:26
brianwelsch14-Aug-02 8:26 
GeneralNeed Help Pin
23-May-02 10:13
suss23-May-02 10:13 
GeneralRe: Need Help Pin
Chris Losinger23-May-02 10:29
professionalChris Losinger23-May-02 10:29 
GeneralRe: Need Help Pin
speedster23-May-02 15:53
speedster23-May-02 15:53 
GeneralRe: Need Help Pin
Ravi Bhavnani20-Jun-02 16:00
professionalRavi Bhavnani20-Jun-02 16:00 
GeneralRe: Need Help Pin
speedster22-Jun-02 5:00
speedster22-Jun-02 5:00 
Wrote a program but having probs can any one help put it right please.

#include<stdio.h>
#define MAX 9999
#define MIN 1000

void read_master(FILE *fp,int *code, int *qty, int *buy, int *sell);
void write_master(FILE *fp,int code, int qty, int buy, int sell);
void read_amend(FILE *fp,int *code, char *type, int *value);



int main()
{
int stk_prod_code, amnd_prod_code, quantity, buy_price, sale_price, new_value;
char type;
FILE *stk_ptr, *amnd_ptr, *newstk_ptr,*query_ptr;

if((stk_ptr=fopen("STOCK.DAT","rt"))==NULL ||
(amnd_ptr=fopen("AMEND.DAT","rt"))==NULL ||
(newstk_ptr=fopen("NEWSTOCK.DAT","wt"))==NULL ||
(query_ptr=fopen("QUERY","wt"))==NULL )

{
printf("error message");
return 1;

}

read_master(stk_ptr, &stk_prod_code, &quantity, &buy_price, &sale_price);
read_amend(amnd_ptr, &amnd_prod_code, &type, &new_value);

while(stk_prod_code !=MAX || amnd_prod_code !=MAX)
{
if(stk_prod_code == amnd_prod_code)
{

switch (type)
{
case 'I':quantity-=new_value;
break;
case 'R':quantity+=new_value;
break;
case 'B':buy_price=new_value;
break;
case 'S':sale_price-=new_value;
break;
case 'D':read_master(stk_ptr, &stk_prod_code, &quantity, &buy_price,
&sale_price);
break;
default:;


}
read_amend(amnd_ptr, &amnd_prod_code, &type, &new_value);

}
else
{
write_master(newstk_ptr, stk_prod_code, quantity, buy_price, sale_price);

if(quantity<min ||="" quantity=""> MAX)
write_master(query_ptr, stk_prod_code, quantity, buy_price, sale_price);
read_master(stk_ptr, &stk_prod_code, &quantity, &buy_price, &sale_price);


write_master(query_ptr, stk_prod_code, quantity, buy_price, sale_price);

fclose(stk_ptr);
fclose(amnd_ptr);
fclose(newstk_ptr);
fclose(query_ptr);
return 0;
}



void read_master(FILE *fp,int *code, int *qty, int *buy, int *sell)
{
if(fscanf(fp, "%d,%d,%d,%d", code, qty, buy, sell)==EOF)
*code=MAX;
}
void write_master(FILE *fp,int code, int qty, int buy, int sell)
{
fprintf(fp,"%d,%d,%d,%d\n", code, qty, buy, sell);

}
void read_amend(FILE *fp,int *code, char *type, int *value)
{
if(fscanf(fp, "%d,%c,%d", code, type, value)==EOF)
*code=MAX;
}
QuestionWindows Installer? Pin
Rene De La Garza23-May-02 6:12
Rene De La Garza23-May-02 6:12 
AnswerRe: Windows Installer? Pin
Philip Patrick23-May-02 9:02
professionalPhilip Patrick23-May-02 9:02 
GeneralShow desktop Pin
obr23-May-02 4:46
obr23-May-02 4:46 
GeneralRe: Show desktop Pin
3-Jun-02 11:16
suss3-Jun-02 11:16 
GeneralRe: Show desktop Pin
TomKat14-Mar-03 15:09
TomKat14-Mar-03 15:09 
Generalusing Winsock Control in VC++ Pin
Speedy20-May-02 11:25
Speedy20-May-02 11:25 
GeneralRe: using Winsock Control in VC++ Pin
l a u r e n20-May-02 12:11
l a u r e n20-May-02 12:11 
GeneralC# TreeView/List Pin
Mika14-May-02 7:35
Mika14-May-02 7:35 
GeneralRe: C# TreeView/List Pin
Mika14-May-02 7:37
Mika14-May-02 7:37 
Generalarticle ideas Pin
Jason Henderson14-May-02 6:29
Jason Henderson14-May-02 6:29 
GeneralRe: article ideas Pin
Michael P Butler15-May-02 22:37
Michael P Butler15-May-02 22:37 
GeneralRe: article ideas Pin
Jason Henderson16-May-02 11:33
Jason Henderson16-May-02 11:33 
Questionhow to save a image using script - jscript or vbscript Pin
CreProDes8-May-02 20:56
CreProDes8-May-02 20:56 
AnswerRe: how to save a image using script - jscript or vbscript Pin
CreProDes8-May-02 21:25
CreProDes8-May-02 21:25 
QuestionHow to programmaticly assign two NICs the same IP Pin
29-Apr-02 18:21
suss29-Apr-02 18:21 
AnswerRe: How to programmaticly assign two NICs the same IP Pin
Matt Newman7-May-02 16:37
Matt Newman7-May-02 16:37 
Generallogin Pin
yamet27-Apr-02 15:01
yamet27-Apr-02 15:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.