473,508 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error

i
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
char ch;
int w;
int n,m;
//void main();
char check(int n,int m,char ch);
void cash(int n,int m,char ch);
void debit_card(int n,int m,char ch);
void creditcard(int n,int m,char ch);
void clear(int n,int m,char ch);
void receipt(int n,int j1);
FILE *fp;
struct ing
{
int co,s,c;
}ingr;
struct debit
{
int dc_n,p;
float bal;
}d[10];
struct credit
{
int cre;
float x;
}ce[10];
void main()
{
/* struct ing
{
int co,s,c;
}ingr;
struct debit
{
int dc_n,p;
float bal;
}d[10];
struct credit
{
int cre;
float x;
}ce[10];*/

char ch1,ch2;
int i,j;
j=1;
printf("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
if(j==1)
{
fp=fopen("ingredient.dat","w");
scanf("%d%d%d",&ingr.co,&ingr.s,&ingr.c);
fwrite(&ingr,sizeof(struct ing),1,fp);
fclose(fp);
fp=fopen("debitCard.dat","w");
for(i=0;i<10;i++)
scanf("%d%d%f",&d[i].dc_n,&d[i].p,&d[i].bal);
fwrite(d,sizeof(struct ing),10,fp);
fclose(fp);
fp=fopen("creditCard.dat","w");
for(i=0;i<10;i++)
scanf("%d%f",&ce[i].cre,&ce[i].x);
fwrite(ce,sizeof(struct credit),10,fp);
fclose(fp);
j++;
}
printf("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
ch=getche();
if(ch=='b')
{
printf("\nEnter no.of Black Coffees");
scanf("%d",&n);
m=0;
}
else
if(ch=='w')
{
printf("\nEnter no.of White Coffees");
scanf("%d",&m);
}
ch2=check(n,m,ch);
if(ch2=='a')
{
printf("\nEnter Mode of Payment\nFor Cash Enter 'c'\nFor debit card
Enter 'd'\nFor Credit card Enter 'r'");
ch1=getche();
if(ch1=='c')
{
cash(n,m,ch);
}
else
if(ch1=='d')
{
debit_card(n,m,ch);
}
else
if(ch1=='r')
{
creditcard(n,m,ch);
}
}
getch();
}
char check(int n,int m,char ch)
{

char g;
fp=fopen("ingredient.dat","r+t");
fread(&ingr,sizeof(struct ing),1,fp);
if(ch=='b')
{
if(ingr.co>=n)
{
g='a';
return(g);
}
else
{
printf("\nThere is not enough coffee powder");
}
}
else
if(ch=='w')
{
if((ingr.co>=m)&&(ingr.s>=m)&&(ingr.c>=m))
{
g='a';
return(g);
}
else
{
printf("\nThere is not enough coffee powder, sugar and creamer");
}
}
return(0);
}
void cash(int n,int m,char ch)
{
int k,l,o,sum=0;

if(ch=='b')
{
scanf("%d%d%d",&k,&l,&o);
while(sum!=(n*6))
{
if((k==10)&&(k==20)&&(k==50)&&(k==100)&&(k==500)&& (k==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&k);
}
if((l==10)&&(l==20)&&(l==50)&&(l==100)&&(l==500)&& (l==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&l);
}
if((o==10)&&(o==20)&&(o==50)&&(o==100)&&(o==500)&& (o==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&o);
}
sum+=k+l+o;
}
if(sum!=0)
{
clear(n,m,ch);
receipt(n,sum);
}
}
else if(ch=='w')
{
scanf("%d%d%d",&k,&l,&o);
while(sum!=(m*10))
{
if((k==10)&&(k==20)&&(k==50)&&(k==100)&&(k==500)&& (k==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&k);
}
if((l==10)&&(l==20)&&(l==50)&&(l==100)&&(l==500)&& (l==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&l);
}
if((o==10)&&(o==20)&&(o==50)&&(o==100)&&(o==500)&& (o==1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&o);
}
sum+=k+l+o;
}
if(sum!=0)
{
clear(n,m,ch);
receipt(m,sum);
}
}

}
void debit_card(int n,int m,char ch)
{

int i,de,pin,j;
fp=fopen("debitCard.dat","r+t");
fread(&d[10],sizeof(struct debit),10,fp);
printf("\nEnter debit card number and pin number");
scanf("%d%d",&de,&pin);
for(i=0;i<sizeof(struct debit);i++)
{
if(ch=='b')
{
j=n*6;
if((de==d[i].dc_n)&&(pin==d[i].p))
{
if(d[i].bal>j)
{
d[i].bal-=j;
fwrite(d,sizeof(struct debit),1,fp);
clear(n,m,ch);
receipt(n,j);
}
else if(d[i].bal<0)
{
printf("\nBalance below zero");
}
else if(d[i].bal<j)
{
printf("\nThere is n enugh money");
}
}
else
printf("\nIncorrect format");
}
else
if(ch=='w')
{
j=m*10;
if((de==d[i].dc_n)&&(pin==d[i].p))
{
if(d[i].bal>j)
{
d[i].bal-=j;
fwrite(d,sizeof(d),1,fp);
clear(n,m,ch);
receipt(n,j);
}
else if(d[i].bal<0)
{
printf("\nBalance below zero");
}
else if(d[i].bal<j)
{
printf("\nThere is no enugh money");
}
}
else
printf("\nIncorrect format");
}
fclose(fp);
}
void creditcard(int n,int m,char ch)
{

int i,j;
fp=fopen("creditCard.dat","r+t");
fread(&ce[10],sizeof(struct credit),10,fp);
printf("\nEnter the credit card number");
scanf("%d",&w);
for(i=0;i<sizeof(struct credit);i++)
{
if(ch=='b')
{
j=n*6;
if(ce[i].cre==w)
{
if(ce[i].x>j)
{
clear(n,m,ch);
receipt(n,j);
}
else
printf("\nver Credit Limit");
}
else
printf("\nIncorrect Format");
}
else
if(ch=='w')
{
j=m*10;
if(ce[i].cre==w)
{
if(ce[i].x>j)
{
clear(n,m,ch);
receipt(m,j);
}
else
{
printf("\nver Credit Limit");
}
}
else
{
printf("\nIncorrect format");
}
}
}
fclose(fp);
}
void clear(int n,int m,char ch)
{
fp=fopen("ingredient.dat","r+t");
if(ch=='b')
{
fread(&ingr,sizeof(struct ing),1,fp);
ingr.co-=n;
fwrite(fp,sizeof(struct ing),1,fp);
printf("\nCoffee served");
fclose(fp);
}
else
if(ch=='w')
{
fread(&ingr,sizeof(struct ing),1,fp);
ingr.co-=m;
ingr.s-=m;
ingr.c-=m;
fwrite(fp,sizeof(struct ing),1,fp);
printf("\nCoffee served");
fclose(fp);
}
}
void receipt(int n,int j1)
{
char ch3;

printf("\n****************************RECEIPT***** *****************************");
printf("\nThe Number of Coffees %d",n);
printf("\nTotal amount of money %f",j1);
printf("\nDo you want to continue order coffee?(y/n)");
ch3=getche();
if(ch3=='y')
{
}
}
Compiling...
MAINP1.C
D:\tc\MAINP1.C(263) : error C2143: syntax error : missing ';' before
'type'
Error executing cl.exe.

MAINP1.OBJ - 1 error(s), 0 warning(s)

May 3 '07 #1
7 3287
"i" <im*********@yahoo.co.inschrieb im Newsbeitrag
news:11*********************@u30g2000hsc.googlegro ups.com...
#include<stdio.h>
#include<conio.h>
no such thing in standard C
#include<process.h>
no such thing in standard C
#include<string.h>
char ch;
int w;
int n,m;
//void main();
no such thing in standard C, C++ style comments should be avoided here
char check(int n,int m,char ch);
void cash(int n,int m,char ch);
void debit_card(int n,int m,char ch);
void creditcard(int n,int m,char ch);
void clear(int n,int m,char ch);
void receipt(int n,int j1);
FILE *fp;
struct ing
{
int co,s,c;
}ingr;
struct debit
{
int dc_n,p;
float bal;
}d[10];
struct credit
{
int cre;
float x;
}ce[10];
void main()
no such thing in standard C
{
/* struct ing
{
int co,s,c;
}ingr;
struct debit
{
int dc_n,p;
float bal;
}d[10];
struct credit
{
int cre;
float x;
}ce[10];*/

char ch1,ch2;
int i,j;
j=1;
printf("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
if(j==1)
{
fp=fopen("ingredient.dat","w");
scanf("%d%d%d",&ingr.co,&ingr.s,&ingr.c);
fwrite(&ingr,sizeof(struct ing),1,fp);
fclose(fp);
fp=fopen("debitCard.dat","w");
for(i=0;i<10;i++)
scanf("%d%d%f",&d[i].dc_n,&d[i].p,&d[i].bal);
fwrite(d,sizeof(struct ing),10,fp);
fclose(fp);
fp=fopen("creditCard.dat","w");
for(i=0;i<10;i++)
scanf("%d%f",&ce[i].cre,&ce[i].x);
fwrite(ce,sizeof(struct credit),10,fp);
fclose(fp);
j++;
}
printf("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
ch=getche();
if(ch=='b')
{
printf("\nEnter no.of Black Coffees");
scanf("%d",&n);
m=0;
}
else
if(ch=='w')
{
printf("\nEnter no.of White Coffees");
scanf("%d",&m);
}
ch2=check(n,m,ch);
if(ch2=='a')
{
printf("\nEnter Mode of Payment\nFor Cash Enter 'c'\nFor debit card
Enter 'd'\nFor Credit card Enter 'r'");
ch1=getche();
if(ch1=='c')
{
cash(n,m,ch);
}
else
if(ch1=='d')
{
debit_card(n,m,ch);
}
else
if(ch1=='r')
{
creditcard(n,m,ch);
}
}
getch();
}
char check(int n,int m,char ch)
{

char g;
fp=fopen("ingredient.dat","r+t");
fread(&ingr,sizeof(struct ing),1,fp);
if(ch=='b')
{
if(ingr.co>=n)
{
g='a';
return(g);
}
else
{
printf("\nThere is not enough coffee powder");
}
}
else
if(ch=='w')
{
if((ingr.co>=m)&&(ingr.s>=m)&&(ingr.c>=m))
{
g='a';
return(g);
}
else
{
printf("\nThere is not enough coffee powder, sugar and creamer");
}
}
return(0);
}
void cash(int n,int m,char ch)
{
int k,l,o,sum=0;

if(ch=='b')
{
scanf("%d%d%d",&k,&l,&o);
while(sum!=(n*6))
{
if((k==10)&&(k==20)&&(k==50)&&(k==100)&&(k==500)&& (k==1000))
When on earth do you expect this condition to become true?
Or did you mean OR || rather than AND &&?
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&k);
}
if((l==10)&&(l==20)&&(l==50)&&(l==100)&&(l==500)&& (l==1000))
see above
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&l);
}
if((o==10)&&(o==20)&&(o==50)&&(o==100)&&(o==500)&& (o==1000))
see above
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&o);
}
sum+=k+l+o;
}
if(sum!=0)
{
clear(n,m,ch);
receipt(n,sum);
}
}
else if(ch=='w')
{
scanf("%d%d%d",&k,&l,&o);
while(sum!=(m*10))
{
if((k==10)&&(k==20)&&(k==50)&&(k==100)&&(k==500)&& (k==1000))
see above
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&k);
}
if((l==10)&&(l==20)&&(l==50)&&(l==100)&&(l==500)&& (l==1000))
see above
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&l);
}
if((o==10)&&(o==20)&&(o==50)&&(o==100)&&(o==500)&& (o==1000))
see above
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d",&o);
}
sum+=k+l+o;
}
if(sum!=0)
{
clear(n,m,ch);
receipt(m,sum);
}
}

}
void debit_card(int n,int m,char ch)
{

int i,de,pin,j;
fp=fopen("debitCard.dat","r+t");
fread(&d[10],sizeof(struct debit),10,fp);
printf("\nEnter debit card number and pin number");
scanf("%d%d",&de,&pin);
for(i=0;i<sizeof(struct debit);i++)
{
if(ch=='b')
{
j=n*6;
if((de==d[i].dc_n)&&(pin==d[i].p))
{
if(d[i].bal>j)
{
d[i].bal-=j;
fwrite(d,sizeof(struct debit),1,fp);
clear(n,m,ch);
receipt(n,j);
}
else if(d[i].bal<0)
{
printf("\nBalance below zero");
}
else if(d[i].bal<j)
{
printf("\nThere is n enugh money");
}
}
else
printf("\nIncorrect format");
}
else
if(ch=='w')
{
j=m*10;
if((de==d[i].dc_n)&&(pin==d[i].p))
{
if(d[i].bal>j)
{
d[i].bal-=j;
fwrite(d,sizeof(d),1,fp);
clear(n,m,ch);
receipt(n,j);
}
else if(d[i].bal<0)
{
printf("\nBalance below zero");
}
else if(d[i].bal<j)
{
printf("\nThere is no enugh money");
}
}
else
printf("\nIncorrect format");
}
fclose(fp);
}
Somewhere up from here there is a } missing! And that is line 263, the one
youy compiler complains about.
void creditcard(int n,int m,char ch)
{

int i,j;
fp=fopen("creditCard.dat","r+t");
fread(&ce[10],sizeof(struct credit),10,fp);
printf("\nEnter the credit card number");
scanf("%d",&w);
for(i=0;i<sizeof(struct credit);i++)
{
if(ch=='b')
{
j=n*6;
if(ce[i].cre==w)
{
if(ce[i].x>j)
{
clear(n,m,ch);
receipt(n,j);
}
else
printf("\nver Credit Limit");
}
else
printf("\nIncorrect Format");
}
else
if(ch=='w')
{
j=m*10;
if(ce[i].cre==w)
{
if(ce[i].x>j)
{
clear(n,m,ch);
receipt(m,j);
}
else
{
printf("\nver Credit Limit");
}
}
else
{
printf("\nIncorrect format");
}
}
}
fclose(fp);
}
void clear(int n,int m,char ch)
{
fp=fopen("ingredient.dat","r+t");
if(ch=='b')
{
fread(&ingr,sizeof(struct ing),1,fp);
ingr.co-=n;
fwrite(fp,sizeof(struct ing),1,fp);
printf("\nCoffee served");
fclose(fp);
}
else
if(ch=='w')
{
fread(&ingr,sizeof(struct ing),1,fp);
ingr.co-=m;
ingr.s-=m;
ingr.c-=m;
fwrite(fp,sizeof(struct ing),1,fp);
printf("\nCoffee served");
fclose(fp);
}
}
void receipt(int n,int j1)
{
char ch3;

printf("\n****************************RECEIPT***** *****************************");
printf("\nThe Number of Coffees %d",n);
printf("\nTotal amount of money %f",j1);
printf("\nDo you want to continue order coffee?(y/n)");
ch3=getche();
if(ch3=='y')
{
}
}
Compiling...
MAINP1.C
D:\tc\MAINP1.C(263) : error C2143: syntax error : missing ';' before
'type'
Error executing cl.exe.

MAINP1.OBJ - 1 error(s), 0 warning(s)

Bye, Jojo
May 3 '07 #2
i said:

<a few hundred lines of C>
>
Compiling...
MAINP1.C
D:\tc\MAINP1.C(263) : error C2143: syntax error : missing ';' before
'type'
Error executing cl.exe.

MAINP1.OBJ - 1 error(s), 0 warning(s)
foo.c:2: conio.h: No such file or directory
foo.c:3: process.h: No such file or directory
foo.c:50: warning: string constant runs past end of line
make: *** [foo.o] Error 1

Removed two headers, fixed line wrap.

foo.c:67: warning: string constant runs past end of line
foo.c:6: parse error before `/'
foo.c:7: warning: declaration of `n' shadows global declaration
foo.c:7: warning: declaration of `m' shadows global declaration
foo.c:7: warning: declaration of `ch' shadows global declaration
foo.c:8: warning: declaration of `n' shadows global declaration
foo.c:8: warning: declaration of `m' shadows global declaration
foo.c:8: warning: declaration of `ch' shadows global declaration
foo.c:9: warning: declaration of `n' shadows global declaration
foo.c:9: warning: declaration of `m' shadows global declaration

(many more problems elided)

Fixed another line wrap, changed //void main(); to /*void main();*/

Now we get an interesting one - the shadowing. I decided that the
easiest way to fix this was to change the prototypes. To minimise the
strain of remembering what changed to what, I simply appended an
underscore to each one that clashed. This probably wasn't what was
intended - I suspect that you are confused about how to use file scope
objects (to which the obvious answer is "never", and the less obvious
answer (for experts only) is "almost never"):

char check(int n_, int m_, char ch_);
void cash(int n_, int m_, char ch_);
void debit_card(int n_, int m_, char ch_);
void creditcard(int n_, int m_, char ch_);
void clear(int n_, int m_, char ch_);
void receipt(int n_, int j1);

After this change, I was down to 36 diagnostic messages. Here are the
top ten:

foo.c:84: warning: string constant runs past end of line
foo.c:29: warning: function declaration isn't a prototype
foo.c:29: warning: return type of `main' is not `int'
foo.c: In function `main':
foo.c:68: warning: implicit declaration of function `getche'
foo.c:84: warning: ANSI C forbids newline in string constant
foo.c:102: warning: implicit declaration of function `getch'
foo.c: At top level:
foo.c:104: warning: declaration of `n' shadows global declaration
foo.c:104: warning: declaration of `m' shadows global declaration
foo.c:104: warning: declaration of `ch' shadows global declaration
foo.c: In function `check':
foo.c:105: warning: declaration of `ch' shadows global declaration

I fixed some more line wrap, changed void main to int main(void),
replaced all getch and getche calls with getchar calls, and hacked the
functions listed above to promulgate the parameter name changes through
the function declarators and function bodies. That left me with:

foo.c: In function `main':
foo.c:102: warning: control reaches end of non-void function
foo.c: In function `check':
foo.c:103: warning: unused parameter `n_'
foo.c:103: warning: unused parameter `m_'
foo.c: In function `debit_card':
foo.c:207: warning: comparison between signed and unsigned
foo.c:260: parse error before `void'
foo.c:268: warning: comparison between signed and unsigned
foo.c: In function `receipt':
foo.c:341: warning: double format, different type arg (arg 2)
make: *** [foo.o] Error 1

I added:

return 0;

to main to fix the first one on this list. I ignored the two "unused
parameter" messages since this is clearly a work-in-progress and no
doubt they will be used in due course.

I fixed the first comparison between signed and unsigned by changing the
type of i to size_t (in debit_card()).

That brought me to the parse error. This turned out to be a missing
closing-brace in the debit_card() function. It is evident that the file
must not be closed until after the loop is finished, so I added a
closing brace above the fclose call.

I fixed the second comparison between signed and unsigned by changing
the type of i to size_t (in creditcard()).

That brought me to the double format, different type arg diagnostic,
which relates to a %f being used instead of a %d.

Fixing that cleared all the diagnostics except the two about unused
parameters. This left me with a massively broken program that happens
to compile cleanly. At this point, I made my excuses and left:

#include<stdio.h>
#include<string.h>
char ch;
int w;
int n, m;

/* void main(); */
char check(int n_,
int m_,
char ch_);
void cash(int n_,
int m_,
char ch_);
void debit_card(int n_,
int m_,
char ch_);
void creditcard(int n_,
int m_,
char ch_);
void clear(int n_,
int m_,
char ch_);
void receipt(int n_,
int j1);
FILE *fp;
struct ing
{
int co, s, c;
}
ingr;
struct debit
{
int dc_n, p;
float bal;
}
d[10];
struct credit
{
int cre;
float x;
}
ce[10];
int main(void)
{

/* struct ing
{
int co,s,c;
}ingr;
struct debit
{
int dc_n,p;
float bal;
}d[10];
struct credit
{
int cre;
float x;
}ce[10];*/

char ch1, ch2;
int i, j;

j = 1;
printf
("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
if(j == 1)
{
fp = fopen("ingredient.dat", "w");
scanf("%d%d%d", &ingr.co, &ingr.s, &ingr.c);
fwrite(&ingr, sizeof (struct ing), 1, fp);
fclose(fp);
fp = fopen("debitCard.dat", "w");
for(i = 0; i < 10; i++)
scanf("%d%d%f", &d[i].dc_n, &d[i].p, &d[i].bal);
fwrite(d, sizeof (struct ing), 10, fp);
fclose(fp);
fp = fopen("creditCard.dat", "w");
for(i = 0; i < 10; i++)
scanf("%d%f", &ce[i].cre, &ce[i].x);
fwrite(ce, sizeof (struct credit), 10, fp);
fclose(fp);
j++;
}
printf
("\nFor Black Coffee\t\t Enter 'b'\nFor White Coffee\t\t Enter
'w'");
ch = getchar();
if(ch == 'b')
{
printf("\nEnter no.of Black Coffees");
scanf("%d", &n);
m = 0;
}
else if(ch == 'w')
{
printf("\nEnter no.of White Coffees");
scanf("%d", &m);
}
ch2 = check(n, m, ch);
if(ch2 == 'a')
{
printf
("\nEnter Mode of Payment\nFor Cash Enter 'c'\nFor debit card
Enter 'd'\nFor Credit card Enter 'r'");
ch1 = getchar();
if(ch1 == 'c')
{
cash(n, m, ch);
}
else if(ch1 == 'd')
{
debit_card(n, m, ch);
}
else if(ch1 == 'r')
{
creditcard(n, m, ch);
}
}
getchar();
return 0;
}
char check(int n_,
int m_,
char ch_)
{
char g;

fp = fopen("ingredient.dat", "r+t");
fread(&ingr, sizeof (struct ing), 1, fp);
if(ch_ == 'b')
{
if(ingr.co >= n)
{
g = 'a';
return (g);
}
else
{
printf("\nThere is not enough coffee powder");
}
}
else if(ch_ == 'w')
{
if((ingr.co >= m) && (ingr.s >= m) && (ingr.c >= m))
{
g = 'a';
return (g);
}
else
{
printf("\nThere is not enough coffee powder, sugar and creamer");
}
}
return (0);
}
void cash(int n_,
int m_,
char ch_)
{
int k, l, o, sum = 0;

if(ch_ == 'b')
{
scanf("%d%d%d", &k, &l, &o);
while(sum != (n_ * 6))
{
if((k == 10) && (k == 20) && (k == 50) && (k == 100) && (k == 500)
&& (k == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &k);
}
if((l == 10) && (l == 20) && (l == 50) && (l == 100) && (l == 500)
&& (l == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &l);
}
if((o == 10) && (o == 20) && (o == 50) && (o == 100) && (o == 500)
&& (o == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &o);
}
sum += k + l + o;
}
if(sum != 0)
{
clear(n_, m_, ch_);
receipt(n_, sum);
}
}
else if(ch_ == 'w')
{
scanf("%d%d%d", &k, &l, &o);
while(sum != (m * 10))
{
if((k == 10) && (k == 20) && (k == 50) && (k == 100) && (k == 500)
&& (k == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &k);
}
if((l == 10) && (l == 20) && (l == 50) && (l == 100) && (l == 500)
&& (l == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &l);
}
if((o == 10) && (o == 20) && (o == 50) && (o == 100) && (o == 500)
&& (o == 1000))
{
printf("\nInvalid Cash.Give only 1,2 and 5 rupee coins");
scanf("%d", &o);
}
sum += k + l + o;
}
if(sum != 0)
{
clear(n_, m_, ch_);
receipt(m_, sum);
}
}

}
void debit_card(int n_,
int m_,
char ch_)
{

int de, pin, j;
size_t i;

fp = fopen("debitCard.dat", "r+t");
fread(&d[10], sizeof (struct debit), 10, fp);
printf("\nEnter debit card number and pin number");
scanf("%d%d", &de, &pin);
for(i = 0; i < sizeof (struct debit); i++)
{
if(ch_ == 'b')
{
j = n_ * 6;
if((de == d[i].dc_n) && (pin == d[i].p))
{
if(d[i].bal j)
{
d[i].bal -= j;
fwrite(d, sizeof (struct debit), 1, fp);
clear(n_, m_, ch_);
receipt(n_, j);
}
else if(d[i].bal < 0)
{
printf("\nBalance below zero");
}
else if(d[i].bal < j)
{
printf("\nThere is n enugh money");
}
}
else
printf("\nIncorrect format");
}
else if(ch_ == 'w')
{
j = m_ * 10;
if((de == d[i].dc_n) && (pin == d[i].p))
{
if(d[i].bal j)
{
d[i].bal -= j;
fwrite(d, sizeof (d), 1, fp);
clear(n_, m_, ch_);
receipt(n, j);
}
else if(d[i].bal < 0)
{
printf("\nBalance below zero");
}
else if(d[i].bal < j)
{
printf("\nThere is no enugh money");
}
}
else
printf("\nIncorrect format");
}
}
fclose(fp);
}
void creditcard(int n_,
int m_,
char ch_)
{

int j;
size_t i;

fp = fopen("creditCard.dat", "r+t");
fread(&ce[10], sizeof (struct credit), 10, fp);
printf("\nEnter the credit card number");
scanf("%d", &w);
for(i = 0; i < sizeof (struct credit); i++)
{
if(ch_ == 'b')
{
j = n_ * 6;
if(ce[i].cre == w)
{
if(ce[i].x j)
{
clear(n_, m_, ch_);
receipt(n_, j);
}
else
printf("\nver Credit Limit");
}
else
printf("\nIncorrect Format");
}
else if(ch_ == 'w')
{
j = m_ * 10;
if(ce[i].cre == w)
{
if(ce[i].x j)
{
clear(n_, m_, ch_);
receipt(m_, j);
}
else
{
printf("\nver Credit Limit");
}
}
else
{
printf("\nIncorrect format");
}
}
}
fclose(fp);
}
void clear(int n_,
int m_,
char ch_)
{
fp = fopen("ingredient.dat", "r+t");
if(ch_ == 'b')
{
fread(&ingr, sizeof (struct ing), 1, fp);
ingr.co -= n_;
fwrite(fp, sizeof (struct ing), 1, fp);
printf("\nCoffee served");
fclose(fp);
}
else if(ch_ == 'w')
{
fread(&ingr, sizeof (struct ing), 1, fp);
ingr.co -= m_;
ingr.s -= m_;
ingr.c -= m_;
fwrite(fp, sizeof (struct ing), 1, fp);
printf("\nCoffee served");
fclose(fp);
}
}
void receipt(int n_,
int j1)
{
char ch3;

printf

("\n****************************RECEIPT*********** ***********************");
printf("\nThe Number of Coffees %d", n_);
printf("\nTotal amount of money %d", j1);
printf("\nDo you want to continue order coffee?(y/n)");
ch3 = getchar();
if(ch3 == 'y')
{
}
}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
May 3 '07 #3
i wrote:
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
The usual "not standard C" admonishments apply here.

[...]
printf("\nIncorrect format");
}
fclose(fp);
}
You probably need another closing brace here.
May 3 '07 #4
Clever Monkey said:
i wrote:
>#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>

The usual "not standard C" admonishments apply here.

[...]
> printf("\nIncorrect format");
here, really.
> }
fclose(fp);
}
You probably need another closing brace here.
But not exactly there. More like

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
May 3 '07 #5
Richard Heathfield wrote:
Clever Monkey said:
>i wrote:
>>#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
The usual "not standard C" admonishments apply here.

[...]
>> printf("\nIncorrect format");

here, really.
>> }
fclose(fp);
}
You probably need another closing brace here.

But not exactly there. More like
Heh. Both ways compile, I guess. Just goes to show. My quick scan of
the logic couldn't really make sense of what was going on, but if I run
your changes through indent it makes more sense.
May 3 '07 #6
"i <im*********@yahoo.co.in>" wrote line after line of the ugliest,
non-portable code I've seen in a long time:
[...]
Compiling...
MAINP1.C
D:\tc\MAINP1.C(263) : error C2143: syntax error : missing ';' before
'type'
Error executing cl.exe.

MAINP1.OBJ - 1 error(s), 0 warning(s)
If you got no more diagnostics than that, you've got your warning level
set _way_ too low.
May 3 '07 #7
On Thu, 03 May 2007 12:25:35 -0400, Martin Ambuhl
<ma*****@earthlink.netwrote:
"i <im*********@yahoo.co.in>" wrote line after line of the ugliest,
non-portable code I've seen in a long time:
[...]
Compiling...
MAINP1.C
D:\tc\MAINP1.C(263) : error C2143: syntax error : missing ';' before
'type'
Error executing cl.exe.

MAINP1.OBJ - 1 error(s), 0 warning(s)

If you got no more diagnostics than that, you've got your warning level
set _way_ too low.
Or an implementor who took far too much advantage of 5.1.1.3. <G>

- formerly david.thompson1 || achar(64) || worldnet.att.net
May 21 '07 #8

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

Similar topics

2
4359
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
2938
by: Gregory | last post by:
Hi, One of the disadvantages of using error handling with error codes instead of exception handling is that error codes retuned from a function can be forgotten to check thus leading to...
13
6572
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
4979
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
16192
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
12002
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
3264
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
0
4716
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
2
19403
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
7223
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,...
0
7321
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
7377
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
7034
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...
1
5045
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.