whats wrong with my code??

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

whats wrong with my code??

 
0
  #1
Jan 4th, 2008
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. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: whats wrong with my code??

 
0
  #2
Jan 4th, 2008
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?
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: whats wrong with my code??

 
0
  #3
Jan 4th, 2008
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
one here
  1. int i=0,j=0,counter=0;
and at
  1. set_deck(deck);
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: whats wrong with my code??

 
0
  #4
Jan 4th, 2008
void set_deck(cards deck[])
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: whats wrong with my code??

 
0
  #5
Jan 4th, 2008
thankyou
now i have just one error in
  1. int i=0,j=0,counter=0;
=\
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: Great_qiang is an unknown quantity at this point 
Solved Threads: 0
Great_qiang's Avatar
Great_qiang Great_qiang is offline Offline
Newbie Poster

Re: whats wrong with my code??

 
0
  #6
Jan 4th, 2008
you should take the
int i=0 ;
int j=0;
int counter =0 ;
before clrscr();
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: whats wrong with my code??

 
0
  #7
Jan 4th, 2008
yess thenkyou very much
one more thing....
how do i do outtextxy to a int??
like printf("%d",a); only in outtextxy...
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: whats wrong with my code??

 
0
  #8
Jan 4th, 2008
Originally Posted by dv1r View Post
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?
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,813
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 747
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: whats wrong with my code??

 
0
  #9
Jan 4th, 2008
>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.
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: whats wrong with my code??

 
0
  #10
Jan 4th, 2008
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 =\
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC