Card Trick

Help neededf

Page 1 of 1

14 Replies - 3602 Views - Last Post: 20 October 2010 - 10:45 PM Rate Topic: -----

#1 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Card Trick

Posted 20 October 2010 - 09:22 PM

I have been assigned to write a program to perform a card trick. This program will create a random deck of cards, deal them out, pick them up, and determine the "secret card", which is the card a user has been following. They way it works: Three columns of cards are dealt, each containing seven cards. The user will then pick a card. The program will ask which column contains their card, and then proceed to shuffle the cards back together. After this has happened three times, the program will find the card the user has been following. The real life example of this trick can be better explained here: http://www.wikihow.c...ven-Card-Trick. Every time I have attempted to do anything with this program I have become extremely frustrated and very negative. Programming has never been my strong suit and this is my final class that involves programming for my degree. Any help will be much appreciated! This is due at midnight tomorrow so I need to figure this out quickly.


This is the base code including what I have so far:

/* 
 * Write a program that performs a cardtrick. The program will create a
 * random deck of cards, deal them out, pick them up, and determine the
 * secret card.
 *
*/

#include <stdio.h>
#include <time.h>

#define SIZE 52

/* Function Prototypes */
void BuildDeck( int deck[], int size );
void PrintDeck( int deck[], int size );
void PrintCard( int card );
void Deal( int deck[], int play[][3] );
void PickUp( int deck[], int play[][3], int column );
void SecretCard( int deck[] );

int main() 
{
/* declare and initialize variables */
char SeeDeck = '';
char PlayAgain = '';
char name[30] = "";
int column = 0, i = 0;

/* Declare a 52 element array of integers to be used as the deck of cards */
int deck[52] = { 0 };

/* Declare a 7 by 3 array to receive the cards dealt to play the trick */
int play[7][3] = { 0 };

/* Generate a random seed for the rand() function. */



/* Openning message.  Ask the player for his/her name */
printf("\nHello, I am a computer program that is so smart\n");
printf("I can even perform a card trick.  Here's how.\n\n");
printf("To begin the card trick type in your name: ");
scanf("%s", name);
/* Capitalize the first letter of the person's name. */


printf("\nThank you %s.\n\n", name);

do
    {
    /* Build the deck */
    BuildDeck(deck, SIZE);

    /* Ask if the player wants to see the entire deck. If so, print it out. */
    printf("Ok %s, first things first.  Do you want to see what \n", name);
    printf("the deck of cards looks like (y/n)? ");
    scanf("%c", &SeeDeck);
    SeeDeck = tolower(SeeDeck);

    
    
    printf("\n%s, pick a card and remember it...\n", name);

    /* Begin the card trick loop */
    for(i = 0; i < 3; i++)
    {
        /* Begin the trick by calling the function to deal out the first 21 cards */

        
        

        /* Include error checking for entering which column */
        do
        {
            /* Ask the player to pick a card and identify the column where the card is */
            printf("\nWhich column is your card in (0, 1, or 2)?: ");
        } while(scanf("%d", &column)==0 || column < 0 || column > 2);
      
        /* Pick up the cards, by column, with the selected column second */
        
        
        
    }

    /* Display the top ten cards, then reveal the secret card */

    
    

    /* if the player wants to play again */
    printf("%s, would you like to play again (y/n)? ", name);
    scanf(" %c", &PlayAgain);
    PlayAgain = tolower(PlayAgain); 
} while(PlayAgain == 'y');

/* Exiting message */
printf("\n\nThank you for playing the card trick!\n\n");
return;
}

void BuildDeck( int deck[], int size )
{
  int used[52] = {0};
  int card = 0, i = 0;

  /* Generate cards until the deck is full of integers */
  while(i < size)
    {
        /* generate a random number between 0 and 51 */
        
        
        /* Check the used array at the position of the card.  
           If 0, add the card and set the used location to 1.  If 1, generate another number */
        if(used[card] == 0)
        {
        
        }
    }
    return;
}

void PrintDeck( int deck[], int size )
{
    int i;

    /* Print out each card in the deck */
    
    
    
    
}

void Deal( int deck[], int play[][3] )
{
    int row = 0, col = 0, card = 0;

    /* deal cards by passing addresses of cardvalues from
       the deck array to the play array                   */
    printf("\n\n");
    printf("   Column 0           Column 1           Column 2\n");
    printf("=======================================================\n\n");

    
    
    
    
    
    return;
}

void PrintCard( int card )
{
    int rank = 0;
    int suit = 0;

    
    
    
    
    
    
    
    
    
      return;
}

void PickUp( int deck[], int play[][3], int column )
{
  int card = 0, row = 0;


  
  
  
  
  
  
    return;
}

void SecretCard( int deck[] )
{
    int card = 0;

    printf("\nFinding secret card...\n");
    for(card = 0; card < 10; card++)
        PrintCard(deck[card]);

    printf("\nYour secret card is: ", PrintCard(deck[card]);
    return;
}












Once again, thanks for all the help!

Is This A Good Question/Topic? 0
  • +

Replies To: Card Trick

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 09:28 PM

Please give us some more details of your problem.
( a ) Does your code compile?
( b ) Any errors or warnings? If there are then share them with us.
( c ) Is the program producing any output?
( d ) How is the actual output different to what you want / expect? Give details and, ideally, examples.
( e ) What have you already tried to fix it?
Was This Post Helpful? 0
  • +
  • -

#3 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 09:32 PM

I will be honest, I haven't gotten much of anything I tried to work. It does not compile with any errors or warnings, and it cannot have any output yet. I am still working on building the functions PrintCard(), BuildDeck(), and PickUp(). I am definitely a complete noob when it comes to programming. I dont know where to start, and my professor is pretty dry. We pretty much need to figure things out for ourselves.
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 09:47 PM

View Postjrayos, on 21 October 2010 - 01:32 PM, said:

We pretty much need to figure things out for ourselves.


Yep that's pretty much how the subject is taught.
It's a sort the goat from the sheep and the strong survive and the devil take the hindmost type of discipline, both at school and at work.

So, choose one small part you want to work on and make a serious effort and if you have trouble we may be able to help you make it better.
Was This Post Helpful? 0
  • +
  • -

#5 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 09:51 PM

Thanks for the advice!

Ive got most of the functions built now with help from another student in class. The code is not compiling from its current state though. Perhaps you might point me in the right direction?


 *
 * Purpose:
 * Write a program that performs a cardtrick. The program will create a
 * random deck of cards, deal them out, pick them up, and determine the
 * secret card.
 *
*/

#include <stdio.h>
#include <time.h>

#define SIZE 52

/* Function Prototypes */
void BuildDeck( int deck[], int size );
void PrintDeck( int deck[], int size );
void PrintCard( int card );
void Deal( int deck[], int play[][3] );
void PickUp( int deck[], int play[][3], int column );
void SecretCard( int deck[] );

int main() 
{
/* declare and initialize variables */
char SeeDeck = '';
char PlayAgain = '';
char name[30] = "";
int column = 0, i = 0;

/* Declare a 52 element array of integers to be used as the deck of cards */
int deck[52] = { 0 };

/* Declare a 7 by 3 array to receive the cards dealt to play the trick */
int play[7][3] = { 0 };

/* Generate a random seed for the rand() function. */



/* Openning message.  Ask the player for his/her name */
printf("\nHello, I am a computer program that is so smart\n");
printf("I can even perform a card trick.  Here's how.\n\n");
printf("To begin the card trick type in your name: ");
scanf("%s", name);
/* Capitalize the first letter of the person's name. */


printf("\nThank you %s.\n\n", name);

do
    {
    /* Build the deck */
    BuildDeck(deck, SIZE);

    /* Ask if the player wants to see the entire deck. If so, print it out. */
    printf("Ok %s, first things first.  Do you want to see what \n", name);
    printf("the deck of cards looks like (y/n)? ");
    scanf("%c", &SeeDeck);
    SeeDeck = tolower(SeeDeck);

    
    
    printf("\n%s, pick a card and remember it...\n", name);

    /* Begin the card trick loop */
    for(i = 0; i < 3; i++)
    {
        /* Begin the trick by calling the function to deal out the first 21 cards */

        
        

        /* Include error checking for entering which column */
        do
        {
            /* Ask the player to pick a card and identify the column where the card is */
            printf("\nWhich column is your card in (0, 1, or 2)?: ");
        } while(scanf("%d", &column)==0 || column < 0 || column > 2);
      
        /* Pick up the cards, by column, with the selected column second */
        
        
        
    }

    /* Display the top ten cards, then reveal the secret card */

    
    

    /* if the player wants to play again */
    printf("%s, would you like to play again (y/n)? ", name);
    scanf(" %c", &PlayAgain);
    PlayAgain = tolower(PlayAgain); 
} while(PlayAgain == 'y');

/* Exiting message */
printf("\n\nThank you for playing the card trick!\n\n");
return;
}

void BuildDeck( int deck[], int size )
{
int used[52] = {0};

  int card = 0, i = 0;

 

 

  while(i < SIZE)

    {

             

            card = rand() % 52;

           

           

            if(used[card] == 0)

            {

                  used[card] = 1;

                  deck[i] = card;

                  i++;

            }

    }
    return;
}

void PrintDeck( int deck[], int size )
{
    int i;

    /* Print out each card in the deck */
    int rank = 0;

      int suit = 0;

      rank = card % 13;

      suit = card / 13;

 

      switch ( rank )

      {

            case 0:

                  printf( " King" );

                  break;

            case 1:

                  printf( "  Ace" );

                  break;

            case 11:

                  printf( " Jack" );

                  break;

            case 12:

                  printf( "Queen" );

                  break;

            default:

                  printf("%5d", rank);

      }

      switch ( suit )

      {

            case 0:

                  printf( " of clubs   " );

                  break;

            case 1:

                  printf( " of diamonds" );

                  break;

            case 2:

                  printf( " of hearts  " );

                  break;

            case 3:

                  printf( " of spades  " );

                  break;

      } 
    
    
    
}

void Deal( int deck[], int play[][3] )
{
    int row = 0, col = 0, card = 0;

    /* deal cards by passing addresses of cardvalues from
       the deck array to the play array                   */
       
     for( row = 0; row < 7; row++)

      {

            for( col = 0; col < 3; col ++)

            {

                  play[row][col] = deck[i];

                  i++;

                  PrintCard( deck[i] );              

            }

           

      }  
       
    printf("\n\n");
    printf("   Column 0           Column 1           Column 2\n");
    printf("=======================================================\n\n");

    
    
    
    
    
    return;
}

void PrintCard( int card )
{
    int rank = 0;

      int suit = 0;

      rank = card % 13;

      suit = card / 13;

 

      switch ( rank )

      {

            case 0:

                  printf( " King" );

                  break;

            case 1:

                  printf( "  Ace" );

                  break;

            case 11:

                  printf( " Jack" );

                  break;

            case 12:

                  printf( "Queen" );

                  break;

            default:

                  printf("%5d", rank);

      }

      switch ( suit )

      {

            case 0:

                  printf( " of clubs   " );

                  break;

            case 1:

                  printf( " of diamonds" );

                  break;

            case 2:

                  printf( " of hearts  " );

                  break;

            case 3:

                  printf( " of spades  " );

                  break;

      } 

    
    
    
    
    
    
    
    
    
      return;
}

void PickUp( int deck[], int play[][3], int column )
{
  


   int card = 0, i = 0, row = 0;

      int first, last;

 

      switch (column)

      {

      case 0:

            first = 1;

            last = 2;

            break;

      case 1:

            first = 0;

            last = 2;

            break;

      case 2:

            first = 0;

            last = 1;

            break;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][first];

            i++;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][column];

            i++;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][last];

            i++;

      }
  
  
  
  
  
    return;
}

void SecretCard( int deck[] )
{
    int card = 0;

    printf("\nFinding secret card...\n");
    for(card = 0; card < 10; card++)
        PrintCard(deck[card]);

    printf("\nYour secret card is: ", PrintCard(deck[card]);
    return;
}







Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 09:54 PM

Please copy the compiler errors and paste them in here so we can see what they are.
Was This Post Helpful? 0
  • +
  • -

#7 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 09:56 PM

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Users\Jon\Desktop\CardtrickStarterFile.c" -o "C:\Users\Jon\Desktop\CardtrickStarterFile.exe" -ansi -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Users\Jon\Desktop\CardtrickStarterFile.c:29:16: empty character constant
C:\Users\Jon\Desktop\CardtrickStarterFile.c:30:18: empty character constant
C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `PrintDeck':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:153: error: `card' undeclared (first use in this function)
C:\Users\Jon\Desktop\CardtrickStarterFile.c:153: error: (Each undeclared identifier is reported only once
C:\Users\Jon\Desktop\CardtrickStarterFile.c:153: error: for each function it appears in.)

C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `Deal':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:242: error: `i' undeclared (first use in this function)
C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `SecretCard':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:440: error: syntax error before ';' token

Execution terminated
Was This Post Helpful? 0
  • +
  • -

#8 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 10:06 PM

Okay, when you have a list like that the best thing to do is start at the top. Fix one, maybe two then compile again and see what happens. Sometimes one earlier error can cascade multiple children errors so fixing one line may fix hundreds of errors.

Now, these lines look like a good idea
char SeeDeck = '';
char PlayAgain = '';


But they are not.
Get rid of the " ='' " bit and try compiling again.

When you initialise a char variable like that you are, unknowingly I guess, making it a constant and that's not what you wanted to to.
If you wanted to make sure the contain empty values you would need to do this;
char SeeDeck;
char PlayAgain';
SeeDeck = '';
PlayAgain = '';



Tricky isn't it?

Fix them and try again.

This post has been edited by janotte: 20 October 2010 - 10:07 PM

Was This Post Helpful? 0
  • +
  • -

#9 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 10:21 PM

thank you. i applied the change you suggested and it still complies the same:

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Users\Jon\Desktop\CardtrickStarterFile.c" -o "C:\Users\Jon\Desktop\CardtrickStarterFile.exe" -ansi -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Users\Jon\Desktop\CardtrickStarterFile.c:31:11: empty character constant
C:\Users\Jon\Desktop\CardtrickStarterFile.c:32:13: empty character constant
C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `PrintDeck':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:155: error: `card' undeclared (first use in this function)
C:\Users\Jon\Desktop\CardtrickStarterFile.c:155: error: (Each undeclared identifier is reported only once
C:\Users\Jon\Desktop\CardtrickStarterFile.c:155: error: for each function it appears in.)

C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `Deal':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:244: error: `i' undeclared (first use in this function)
C:\Users\Jon\Desktop\CardtrickStarterFile.c: In function `SecretCard':
C:\Users\Jon\Desktop\CardtrickStarterFile.c:442: error: syntax error before ';' token

Execution terminated



also, i think that the int main is incomplete. the functions are never called, the "random seed" is never generated for the rand() function. I am starting to give up on programming altogether. its causes nothing but confusion and stress. lol
Was This Post Helpful? 0
  • +
  • -

#10 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 10:24 PM

View Postjrayos, on 21 October 2010 - 02:21 PM, said:

thank you. i applied the change you suggested and it still complies the same:


Show us the code as it is now.

Whoops
No I am wrong.
Sorry I meant to do this in my earlier post. Not being careful enough.
char SeeDeck;
char PlayAgain';
SeeDeck = ' ';
PlayAgain = ' ';


This post has been edited by janotte: 20 October 2010 - 10:27 PM

Was This Post Helpful? 0
  • +
  • -

#11 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 10:25 PM

/* File: cardtrick.c
 * Programmer:
 * Date:
 * Course: COP 3515
 *
 * Purpose:
 * Write a program that performs a cardtrick. The program will create a
 * random deck of cards, deal them out, pick them up, and determine the
 * secret card.
 *
*/

#include <stdio.h>
#include <time.h>

#define SIZE 52

/* Function Prototypes */
void BuildDeck( int deck[], int size );
void PrintDeck( int deck[], int size );
void PrintCard( int card );
void Deal( int deck[], int play[][3] );
void PickUp( int deck[], int play[][3], int column );
void SecretCard( int deck[] );

int main() 
{
/* declare and initialize variables */
char SeeDeck;
char PlayAgain;
SeeDeck = '';
PlayAgain = '';
char name[30] = "";
int column = 0, i = 0;

/* Declare a 52 element array of integers to be used as the deck of cards */
int deck[52] = { 0 };

/* Declare a 7 by 3 array to receive the cards dealt to play the trick */
int play[7][3] = { 0 };

/* Generate a random seed for the rand() function. */



/* Openning message.  Ask the player for his/her name */
printf("\nHello, I am a computer program that is so smart\n");
printf("I can even perform a card trick.  Here's how.\n\n");
printf("To begin the card trick type in your name: ");
scanf("%s", name);
/* Capitalize the first letter of the person's name. */


printf("\nThank you %s.\n\n", name);

do
    {
    /* Build the deck */
    BuildDeck(deck, SIZE);

    /* Ask if the player wants to see the entire deck. If so, print it out. */
    printf("Ok %s, first things first.  Do you want to see what \n", name);
    printf("the deck of cards looks like (y/n)? ");
    scanf("%c", &SeeDeck);
    SeeDeck = tolower(SeeDeck);

    
    
    printf("\n%s, pick a card and remember it...\n", name);

    /* Begin the card trick loop */
    for(i = 0; i < 3; i++)
    {
        /* Begin the trick by calling the function to deal out the first 21 cards */

        
        

        /* Include error checking for entering which column */
        do
        {
            /* Ask the player to pick a card and identify the column where the card is */
            printf("\nWhich column is your card in (0, 1, or 2)?: ");
        } while(scanf("%d", &column)==0 || column < 0 || column > 2);
      
        /* Pick up the cards, by column, with the selected column second */
        
        
        
    }

    /* Display the top ten cards, then reveal the secret card */

    
    

    /* if the player wants to play again */
    printf("%s, would you like to play again (y/n)? ", name);
    scanf(" %c", &PlayAgain);
    PlayAgain = tolower(PlayAgain); 
} while(PlayAgain == 'y');

/* Exiting message */
printf("\n\nThank you for playing the card trick!\n\n");
return;
}

void BuildDeck( int deck[], int size )
{
int used[52] = {0};

  int card = 0, i = 0;

 

 

  while(i < SIZE)

    {

             

            card = rand() % 52;

           

           

            if(used[card] == 0)

            {

                  used[card] = 1;

                  deck[i] = card;

                  i++;

            }

    }
    return;
}

void PrintDeck( int deck[], int size )
{
    int i;

    /* Print out each card in the deck */
    int rank = 0;

      int suit = 0;

      rank = card % 13;

      suit = card / 13;

 

      switch ( rank )

      {

            case 0:

                  printf( " King" );

                  break;

            case 1:

                  printf( "  Ace" );

                  break;

            case 11:

                  printf( " Jack" );

                  break;

            case 12:

                  printf( "Queen" );

                  break;

            default:

                  printf("%5d", rank);

      }

      switch ( suit )

      {

            case 0:

                  printf( " of clubs   " );

                  break;

            case 1:

                  printf( " of diamonds" );

                  break;

            case 2:

                  printf( " of hearts  " );

                  break;

            case 3:

                  printf( " of spades  " );

                  break;

      } 
    
    
    
}

void Deal( int deck[], int play[][3] )
{
    int row = 0, col = 0, card = 0;

    /* deal cards by passing addresses of cardvalues from
       the deck array to the play array                   */
       
     for( row = 0; row < 7; row++)

      {

            for( col = 0; col < 3; col ++)

            {

                  play[row][col] = deck[i];

                  i++;

                  PrintCard( deck[i] );              

            }

           

      }  
       
    printf("\n\n");
    printf("   Column 0           Column 1           Column 2\n");
    printf("=======================================================\n\n");

    
    
    
    
    
    return;
}

void PrintCard( int card )
{
    int rank = 0;

      int suit = 0;

      rank = card % 13;

      suit = card / 13;

 

      switch ( rank )

      {

            case 0:

                  printf( " King" );

                  break;

            case 1:

                  printf( "  Ace" );

                  break;

            case 11:

                  printf( " Jack" );

                  break;

            case 12:

                  printf( "Queen" );

                  break;

            default:

                  printf("%5d", rank);

      }

      switch ( suit )

      {

            case 0:

                  printf( " of clubs   " );

                  break;

            case 1:

                  printf( " of diamonds" );

                  break;

            case 2:

                  printf( " of hearts  " );

                  break;

            case 3:

                  printf( " of spades  " );

                  break;

      } 

    
    
    
    
    
    
    
    
    
      return;
}

void PickUp( int deck[], int play[][3], int column )
{
  


   int card = 0, i = 0, row = 0;

      int first, last;

 

      switch (column)

      {

      case 0:

            first = 1;

            last = 2;

            break;

      case 1:

            first = 0;

            last = 2;

            break;

      case 2:

            first = 0;

            last = 1;

            break;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][first];

            i++;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][column];

            i++;

      }

      for( row = 0; row < 7; row++)

      {

            deck[i] = play[row][last];

            i++;

      }
  
  
  
  
  
    return;
}

void SecretCard( int deck[] )
{
    int card = 0;

    printf("\nFinding secret card...\n");
    for(card = 0; card < 10; card++)
        PrintCard(deck[card]);

    printf("\nYour secret card is: ", PrintCard(deck[card]);
    return;
}








all i changed was what you suggested
Was This Post Helpful? 0
  • +
  • -

#12 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 10:28 PM

Yes, my fault.
See my mea culpa above.
Was This Post Helpful? 0
  • +
  • -

#13 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 10:38 PM

its fine.. i think i might just have to take a bad grade for this assignment, I have class and i have to work tomorrow until about 10pm my time so i wont have any time to finish it up. any last suggestions before i finish for the night?

and your fix did indeed work. thanks for that
Was This Post Helpful? 0
  • +
  • -

#14 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Card Trick

Posted 20 October 2010 - 10:40 PM

My best tip is that when you are compiling your code allow GCC to tell you about warnings, not just errors. That will help you enormously. Here's what GCC says about your original code when display of warnings is turned on:
dic2.c:25:16: error: empty character constant
dic2.c:26:18: error: empty character constant
dic2.c: In function ‘main’:
dic2.c:34: warning: missing braces around initializer
dic2.c:34: warning: (near initialization for ‘play[0]’)
dic2.c:59: warning: implicit declaration of function ‘tolower’
dic2.c:99: warning: ‘return’ with no value, in function returning non-void
dic2.c:34: warning: unused variable ‘play’
dic2.c: In function ‘BuildDeck’:
dic2.c:118: warning: implicit declaration of function ‘rand’
dic2.c: In function ‘PrintDeck’:
dic2.c:149: error: ‘card’ undeclared (first use in this function)
dic2.c:149: error: (Each undeclared identifier is reported only once
dic2.c:149: error: for each function it appears in.)
dic2.c:142: warning: unused variable ‘i’
dic2.c: In function ‘Deal’:
dic2.c:238: error: ‘i’ undeclared (first use in this function)
dic2.c:225: warning: unused variable ‘card’
dic2.c: In function ‘PickUp’:
dic2.c:355: warning: unused variable ‘card’
dic2.c: In function ‘SecretCard’:
dic2.c:436: error: expected ‘)’ before ‘;’ token
dic2.c:438: error: invalid use of void expression
dic2.c:438: warning: too many arguments for format
dic2.c:438: error: expected ‘;’ before ‘}’ token


Was This Post Helpful? 0
  • +
  • -

#15 jrayos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-September 10

Re: Card Trick

Posted 20 October 2010 - 10:45 PM

ok thank you. I know this forum isn't for getting your hw done for you but if you or anyone else would like to help me finish this up in any way it would help me in a huge way. I am on a very limited time frame and I don't believe i could finish this on my own even if i wanted to. Thanks in advance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1