By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

error

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.