954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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....
sorry if my spelling is bad :P

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
  typedef struct{
  int num,sute,joker,in_use,arr_place;
  } card;




void set_deck(deck[])
   {
     clrscr();

     int i=0,j=0,counter=0;

      for(j=1;j<=4;j++)
	for(i=1;i<=13;i++)
	{
	  deck[counter].num=i;
	  deck[counter].sute=j;
	  deck[counter].joker=0;
	  deck[counter].in_use=0;
	  deck[counter].arr_place=counter;
	 counter++;
	}
      for(i=0;i<2;i++)
       {
	deck[counter].in_use=0;
	deck[counter].num=0;
	deck[counter].sute=0;
	deck[counter].joker=1;
	deck[counter].arr_place=counter;
	counter++;
       }


      for(i=0;i<54;i++)
      {
       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);


      }

   }

   void main(void)

   {
   card deck[54];
   set_deck(deck);
   getch();

   }
dv1r
Light Poster
38 posts since Jan 2008
Reputation Points: 9
Solved Threads: 0
 

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?

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

i get an error when i try to run it...
4 to be exact...
one in this line

void set_deck(deck[])

and one in the line uder this one

{

one here

int i=0,j=0,counter=0;

and at

set_deck(deck);
dv1r
Light Poster
38 posts since Jan 2008
Reputation Points: 9
Solved Threads: 0
 
void set_deck(<strong>cards</strong> deck[])
invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

thankyou
now i have just one error in

int i=0,j=0,counter=0;

=\

dv1r
Light Poster
38 posts since Jan 2008
Reputation Points: 9
Solved Threads: 0
 

you should take the
int i=0 ;
int j=0;
int counter =0 ;
before clrscr();

Great_qiang
Newbie Poster
3 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

yess thenkyou very much :)
one more thing....
how do i do outtextxy to a int??
like printf("%d",a); only in outtextxy...

dv1r
Light Poster
38 posts since Jan 2008
Reputation Points: 9
Solved Threads: 0
 
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?

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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 =\

dv1r
Light Poster
38 posts since Jan 2008
Reputation Points: 9
Solved Threads: 0
 

Use sprintf() to convert an integer to string.

Colin Mac
Posting Whiz
327 posts since Sep 2006
Reputation Points: 78
Solved Threads: 22
 

>is there something like outtextxy for int's or do i have to turn it into a string first???
Good question! How about we take a look at the post immediately above yours:
>how do i do outtextxy to a int??
You have to convert the int to a string first.
It's conclusive then. You have to convert the int to a string first. :icon_rolleyes:

>if there is something like that pleas tell me coz i never learned strings =\
I think we have a solution to this dilemma. Let's look at the post immediately above yours:Search the forum, there are plenty of threads on that particular topic.
Wow! It's like all of your questions are answered before you ask them! :icon_rolleyes:

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You