Results 1 to 3 of 3

Thread: convert address to string value?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    convert address to string value?

    Hi

    Please help. Moving from vb to C++ and can't figure how to get the string value of the address for something like this:

    Code:
    #include <stdio.h>
    
    int main ()
    {
    	// Make 52 cards in deck
    	//define suit and card value for each 
    	int suit;char* cardNom;
    
    	for (int i=1;i<=52;i++)
    	{
    	  suit = i / 13;
    	  switch (suit)
    	  { case 0: cardNom = "Spades";
    	            break;
    	    case 1: cardNom = "Hearts";
    	            break;
    	    case 2: cardNom = "Clubs";
    	            break;
    	    case 3: cardNom = "Diamonds";
    	            break;
    	  }
    
    	 switch (i)
                  { case 0:  cardNom = "Ace of " + char(cardNom);
    	             break;
    	    case 10: cardNom = "Jack of " + char(cardNom);
    				 break;
    	    case 11: cardNom = "Queen of " + char(cardNom);
    				 break;
    	    case 12: cardNom = "King of " + char(cardNom);
    				 break;
    	    default: cardNom = char(i + 1) + " " + char(cardNom);
                     break;
    	  }
    	  printf ("\nCard number: %d" , i);
    	  printf (" is the %d" ,char(cardNom));
    	}
    
      return 0;
    }

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: convert address to string value?

    Learn about proper string handling in C, or perhaps in C++. (C++ is easier, but C is closer to what you're already trying to do.) malloc, free, strcpy, strcat and strlen in C. std::string in C++.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Re: convert address to string value?

    You're handleing the cases like c++ strings although you're a little off. Make cardNom a string and use it like so:
    case 0: cardNom += "Ace of " + cardNom; break;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width