943,526 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1384
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 4th, 2008
0

whats wrong with my code??

Expand Post »
im trying to make a function that will fill an array with numbers but something seems to be wrong =\
its suppose to be cards....
sorry if my spelling is bad

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. typedef struct{
  5. int num,sute,joker,in_use,arr_place;
  6. } card;
  7.  
  8.  
  9.  
  10.  
  11. void set_deck(deck[])
  12. {
  13. clrscr();
  14.  
  15. int i=0,j=0,counter=0;
  16.  
  17. for(j=1;j<=4;j++)
  18. for(i=1;i<=13;i++)
  19. {
  20. deck[counter].num=i;
  21. deck[counter].sute=j;
  22. deck[counter].joker=0;
  23. deck[counter].in_use=0;
  24. deck[counter].arr_place=counter;
  25. counter++;
  26. }
  27. for(i=0;i<2;i++)
  28. {
  29. deck[counter].in_use=0;
  30. deck[counter].num=0;
  31. deck[counter].sute=0;
  32. deck[counter].joker=1;
  33. deck[counter].arr_place=counter;
  34. counter++;
  35. }
  36.  
  37.  
  38. for(i=0;i<54;i++)
  39. {
  40. printf("no. %d sute %d in use %d joker %d the I is %d arr_place %d\n",deck[i].num,deck[i].sute,deck[i].in_use,deck[i].joker,i,deck[i].arr_place);
  41.  
  42.  
  43. }
  44.  
  45. }
  46.  
  47. void main(void)
  48.  
  49. {
  50. card deck[54];
  51. set_deck(deck);
  52. getch();
  53.  
  54. }
Similar Threads
Reputation Points: 9
Solved Threads: 0
Light Poster
dv1r is offline Offline
38 posts
since Jan 2008
Jan 4th, 2008
0

Re: whats wrong with my code??

im trying to make a function that will fill an array with numbers but something seems to be wrong =\
its suppose to be cards....

-----------------------------------
What's wrong? it doesn't run as you expect or it shows the error when trying to compile?
Reputation Points: 350
Solved Threads: 63
Posting Pro
invisal is offline Offline
562 posts
since Mar 2005
Jan 4th, 2008
0

Re: whats wrong with my code??

i get an error when i try to run it...
4 to be exact...
one in this line
  1. void set_deck(deck[])
and one in the line uder this one
  1. {
one here
  1. int i=0,j=0,counter=0;
and at
  1. set_deck(deck);
Reputation Points: 9
Solved Threads: 0
Light Poster
dv1r is offline Offline
38 posts
since Jan 2008
Jan 4th, 2008
0

Re: whats wrong with my code??

void set_deck(cards deck[])
Reputation Points: 350
Solved Threads: 63
Posting Pro
invisal is offline Offline
562 posts
since Mar 2005
Jan 4th, 2008
0

Re: whats wrong with my code??

thankyou
now i have just one error in
  1. int i=0,j=0,counter=0;
=\
Reputation Points: 9
Solved Threads: 0
Light Poster
dv1r is offline Offline
38 posts
since Jan 2008
Jan 4th, 2008
0

Re: whats wrong with my code??

you should take the
int i=0 ;
int j=0;
int counter =0 ;
before clrscr();
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Great_qiang is offline Offline
3 posts
since Dec 2007
Jan 4th, 2008
0

Re: whats wrong with my code??

yess thenkyou very much
one more thing....
how do i do outtextxy to a int??
like printf("%d",a); only in outtextxy...
Reputation Points: 9
Solved Threads: 0
Light Poster
dv1r is offline Offline
38 posts
since Jan 2008
Jan 4th, 2008
0

Re: whats wrong with my code??

Click to Expand / Collapse  Quote originally posted by dv1r ...
yess thenkyou very much
one more thing....
how do i do outtextxy to a int??
like printf("%d",a); only in outtextxy...
What is outtextxy?
Reputation Points: 350
Solved Threads: 63
Posting Pro
invisal is offline Offline
562 posts
since Mar 2005
Jan 4th, 2008
0

Re: whats wrong with my code??

>What is outtextxy?
It's a function from BGI's graphics.h library that writes a string to the screen at specific x,y coordinates.

>how do i do outtextxy to a int??
You have to convert the int to a string first. Search the forum, there are plenty of threads on that particular topic.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jan 4th, 2008
0

Re: whats wrong with my code??

is there something like outtextxy for int's or do i have to turn it into a string first???
if there is something like that pleas tell me coz i never learned strings =\
Reputation Points: 9
Solved Threads: 0
Light Poster
dv1r is offline Offline
38 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: How should I code this?
Next Thread in C Forum Timeline: linked list error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC