I have attached a program (unfinished)
I have a problem in the second case that I can't fix.
I tried everything I know.
I think the problem is it can't receive the right info even thoug it should.
can any one help me please?
I have attached a program (unfinished)
I have a problem in the second case that I can't fix.
I tried everything I know.
I think the problem is it can't receive the right info even thoug it should.
can any one help me please?
> gets(Date);
Don't you mean 'date'? There is no 'Date' in your program.
Also, NEVER use gets. Use fgets instead.
> while(choice!='9')
You use 'choice' uninitialized here. This is bad. Initialize it first.
Other than that, I got tired of reading. Post what your program isn't doing correctly and then perhaps you'll get a bit more help.
[edit]
Your date check can REALLY be simplified.
[/edit]Code:int dpm[12] = {31,28,31,30,31,30,31,30,31,31,30,31}; if( day < 1 || day > dpm[month-1] ) { printf("Enter a valid day, between 1 and %d.\n", dpm[month-1]); }
Naturally you will want to modify slightly for leap year.
Quzah.
Last edited by quzah; 05-22-2002 at 05:53 PM.
Hope is the first step on the road to disappointment.
Also,
Do us a favor - cause we love you so much -
void main()
->
Code:int main() { .... return 0; }
I know ,I know int main is better but we can't use in this course.Also,
Do us a favor - cause we love you so much -
void main()
->
Code:int main() { .... return 0; }
so I'll have to keep void main. sorry.
quzah,
thanks for the MUCH better date check.
QUOTE]
Post what your program isn't doing correctly and then perhaps you'll get a bit more help.
[/QUOTE]
this is the part I think gets me into an endless loop but I don't know why.
Code:printf("enter item's id, max 999999999\n"); fgets(item_id,10,stdin); if(sscanf(item_id,"%d",&itemid)==1) { ...............
I still don't know why that way is not working
but I fixed it with an internal function instead.
I would still like to know why this isn't working.
*************************************
printf("enter item's id, max 999999999\n");
fgets(item_id,10,stdin);
if(sscanf(item_id,"%d",&itemid)==1)
{ ...............
*************************************
thanks.
- 999999999 is way bigger than an int. Don't expect you program to work with numbers that big (unless you change the data types).Code:printf("enter item's id, max 999999999\n"); fgets(item_id,10,stdin); if(sscanf(item_id,"%d",&itemid)==1) {
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]