The code is working as I want it to. I am supposed to use pointer syntax, and this seems to me working.
I just wanted to run it past some of the people who know what they're doing first.
/*===============================================================*/
void add()
{
int vala, valb, valc, count=0, bog = 5;
char alakazam, supah[maxstr];
double log[5], vald, valf;
init_costs(log, bog);
clearer();
do
{
{
vala = getint("Product Number", mnum, maxnum);
clearer();
valb = getint("Product Type", mtype, maxtype);
clearer();
valc = getint("Quantity", minquan, maxquan);
getstring(supah, supah);
clearer();
vald = getreal("Cost", mincost, maxcost);
clearer();
log[valb-1] += vald * valc;
valf = getreal("Price", minprice, maxprice);
clearer();
show(vala, valc, vald, valf, supah);
}
show_costs(log, vald, count);
printf("Again? (Y/N)");
scanf("%c%*c", &alakazam);
}
while(alakazam == 'Y' || alakazam == 'y');
return;
}
/*====================================================================*/
double getreal(char word[], double min, double max)
{
int err;
double value;
do
{
printf("\nEnter %s between %.0lf and %.0lf: ", word, min, max);
scanf("%lf%*c", &value);
err = (value < min) || (value > max);
if (err) error(min, max);
}
while (err);
return (value);
}
/*===========================================================*/
double init_costs(double *po, int c)
{
int i;
for(i=0; i < c; i++);
{
*(po + i) = 0;
}
return 0;
}
/*====================================================================*/
double show_costs(double *poi, double molah, int count)
{
int *mn;
double *molahpnt;
molahpnt = &molah;
mn = &count;
printf("\n\n\nType-------------------------Cost\n");
*(poi + *mn);
printf("%d:---------------------------%lf\n", *mn, *molahpnt);
*mn++;
return 0;
}
/*====================================================================*/
By the way, one thing I am having a problem with is with show_costs();. When I run the script of this, I want it's output to look like:
Type----------------Cost
0--------------------/*input prices*/
1--------------------/*input prices*/ /*I want this to show even when nothing has been input*/
2--------------------/*input prices*//*I want this to show even when nothing has been input*/
3--------------------/*input prices*//*I want this to show even when nothing has been input*/
4--------------------/*input prices*//*I want this to show even when nothing has been input*/
But I get:
Type-----------------------Cost
0---------------------------/*Input price*/
Every time I run it. What can I do to fix that?